To generate a random integer, we can use python random.randint() and numpy.random.randint(), however, they are different. In this tutorial, we will discuss the difference between them.
To use python random.randint(), you can read this tutorial.
Numpy random.randint() also can generate a random integer.
numpy.random.randint(low, high=None, size=None, dtype='l')
The value of result is in [low, high).
However, as to python random.randint(), the value of result is in [low, high].
This is the main difference between them.
import random import numpy as np random_py = random.randint(1,5) random_np = np.random.randint(1,5)
The random_py is in [1,5], which means it can be 1, 2, 3, 4, 5
However, random_np is in [1,5), which means it can be 1, 2, 3, 4.