import numpy as np np.random.randint(2, size=10) # array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0]) np.random.randint(5, size=(2, 4)) #array([[4, 0, 2, 1], # [3, 2, 2, 0]])