Logo

Programming-Idioms

History of Idiom 69 > diff from v19 to v20

Edit summary for version 20 by :

Version 19

2015-10-29, 14:05:15

Version 20

2015-10-31, 14:45:29

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Imports
import random
Code
rand = random.Random(s)
Comments bubble
this creates a new random generator rand
Doc URL
https://docs.python.org/3/library/random.html