How to Generate a Random Value Based On an Array of Values in NumPy


In this example, we will learn how to generate a random value based on an array of values in Python NumPy.

Source Code

from numpy import random

n = random.choice([1, 2, 3, 4, 5, 6])

print(n)

Output:

3

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments