Friday, September 3, 2021

Using NumPy's 'random' package (randint and shuffle)



randint

>>> np.random.randint(4) 0 >>> np.random.randint(4) 3 >>> np.random.randint(4) 2 >>> np.random.randint(4) 0

shuffle

>>>arr = np.arange(10) >>>np.random.shuffle(arr) >>>arr [1 7 5 2 9 4 3 6 0 8] # random - - - >>> import numpy as np >>> arr = [0, 1, 2, 3] >>> np.random.shuffle(arr) >>> arr [1, 0, 2, 3] >>> np.random.shuffle(arr) >>> arr [0, 1, 3, 2] >>> Tags: Technology,Python,NumPy

No comments:

Post a Comment