Module random

Official Python documentation


Purpose


Basics


Essential functions

random()

Returns a random float value v such that 0.0 ≤ v < 1.0

randrange( b )

Returns an integer v such that 0 ≤ v < 10; that is, the base ten digits 0 through 9

randrange( a, b )

Returns an integer v such that 31 ≤ v < 41.

randrange( a, b, s )

Returns a random odd number v between 1 and 100.

choice( s )

Returns a random vowel

Returns a random day of the weekend

shuffle( s )

The contents of rgb are now in an unpredictable order

seed( a )

Uses the current time in the set up of the random number generator. As the current time is always changing, there should be different random numbers for each program run.

Uses 1112 in the set up of the random number generator