Question #370
Submitted by

**Answiki**on 01/10/2021 at 12:38:25 PM UTC# In Python, how to create an NumPy array of random integers?

Merged questions

Answer
Submitted by

**Answiki**on 01/10/2021 at 12:38:01 PM UTCThe 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]])
```

Question by

**Answiki**01/10/2021 at 12:38:25 PM
In Python, how to create an NumPy array of random integers?

Answer by

**Answiki**on 01/10/2021 at 12:38:01 PMThe 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]])
```

Question by

**Answiki**01/10/2021 at 12:31:48 PM
In Python, how to create an array of n x m random integers?

# | ID | Query | URL | Count |
---|

Icons proudly provided by Friconix.