Seed function doubt

please explain seed function again.

Hello @vatsal50, seed allows us to get the same set of the random numbers again and again.
for eg.,

np.random.seed(3)
np.random.randint(1,1000) 
# Output: 875
np.random.seed(4)
np.random.randint(1,1000) 
# Output: 623
np.random.randint(1,1000)
# Output: 230
np.random.randint(1,1000)
# Output: 129
np.random.seed(3)
np.random.randint(1,1000)
# Output: 875
np.random.seed(4)
np.random.randint(1,1000) 
# Output: 623

These are some of the examples. We can see if we have used the seed value as 3, we get the answer as 875, and if we use any other seed value or if we don’t use any we get a different value. But if we again use the same seed value, we again get the value 875, and it is the same if we use seed value 4.
So this 875 or 623 these outputs are just examples don’t try to think for seed value 3 you will get 875. It is totally randomly generated no. It is guaranteed in the same function or the same call I get the same no. on the same seed value.
I hope it is clear to you. In case if there is any confusion pls let me know.
And if it is clear to you pls mark it as resolve and feel free to provide the feedback.
Thanks :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.