Ad

What Are Use Cases To Hand Over Different Numbers In Random.seed( 0 )

- 1 answer

What are use cases to hand over different numbers in random.seed(0)?

import random
random.seed(0)
random.random() 

For example, to use random.seed(17) or random.seed(9001) instead of always using random.seed(0). Both return the same "pseudo" random numbers that can be used for testing.

import random
random.seed(17)
random.random() 

Why dont use always random.seed(0)?

Ad

Answer

The seed is saying "random, but always the same randomness". If you want to randomize, e.g. search results, but not for every search you could pass the current day.

If you want to randomize per user you could use a user ID and so on.

Ad
source: stackoverflow.com
Ad