Home / Python Numpy / How to Generate a Random Value Based On an Array of Values in NumPy In this example we will show 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