5.3.1 The Random Number Generator Interface

The Random Number Generator interface describes the methods which are available for all random number generators. This will be enhanced in future releases of Python.

In this release of Python, the modules random, whrandom, and instances of the whrandom.whrandom class all conform to this interface.

choice (seq)
Chooses a random element from the non-empty sequence seq and returns it.

randint (a, b)
Returns a random integer N such that a <= N <= b.

random ()
Returns the next random floating point number in the range [0.0 ... 1.0).

uniform (a, b)
Returns a random real number N such that a <= N < b.


Send comments on this document to python-docs@python.org.