👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
In Python, how to create an array of n x m random integers?
The NumPy function numpy.random.randint(low, high=None, size=None, dtype='l')
is devoted to return random numbers. By setting the size option, the function can return a numpy.ndarray
of random integer :
>>> import numpy as np
>>> np.random.randint(low = 0, high = 10, size=(3,2))
array([[8, 7],
[8, 2],
[6, 2]])