mathematics random the random module provides variety of functions for generating pseudo-random numbers as well as functions for randomly generating values according to various distributions on the real numbers most of the functions in this module depend on the function random()which generates uniformly distributed numbers in the range [ using the mersenne twister generator seeding and initialization the following functions are used to control the state of the underlying random number generatorseed([ ]initializes the random number generator if is omitted or nonethe system time is used to seed the generator otherwiseif is an integer or long integerits value is used if is not an integerit must be hashable object and the value of hash(xis used as seed getstate(returns an object representing the current state of the generator this object can later be passed to setstate(to restore the state setstate(staterestores the state of the random number generator from an object returned by getstate(jumpahead(nquickly changes the state of the generator to what it would be if random(were called times in row must be nonnegative integer random integers the following functions are used to manipulate random integers getrandbits(kcreates long integer containing random bits randint( ,breturns random integerxin the range < < randrange(start,stop [,step]returns random integer in range(start,stop,stepdoes not include the endpoint random sequences the following functions are used to randomize sequence data choice(seqreturns random element from the nonempty sequence seq lib fl ff