np random seed

import numpy as np
np.random.seed(42)
random_numbers = np.random.random(size=4)
random_numbers

Here is what the above code is Doing:
1. We set the random seed to 42.
2. We generate an array of 4 random numbers between 0 and 1.
3. We print the array.

Note that we’ll always get the same output if we run the same code again. That’s because each time we run this code, we’ll be initializing the random number generator with the same seed, 42. So it will generate the same sequence of random numbers.

If we want to generate a different sequence of random numbers, all we have to do is change the random seed. For example, if we change the seed to 20, we get the following output: