NumPy random

  • Post category:NumPy

In this NumPy tutorial, you’ll learn how to use the NumPy random function in Python.

# import numpy module
import numpy as np

# create a numpy array
var = np.random.rand(5,3)

# print the array
print(var)

# shape of the array
print(var.shape)

Output:

[[0.17609767 0.90839447 0.57346046]
 [0.95209471 0.01998423 0.76918367]
 [0.60067472 0.09826133 0.4146737 ]
 [0.0308449  0.73057199 0.57694488]
 [0.53956028 0.70872615 0.86996062]]
(5, 3)

Free resources to learn advanced skills: AiHints and CodeAllow