rand -- Python library reference



Next: whrandom Prev: math Up: Miscellaneous Services Top: Top

5.2. Standard Module rand

This module implements a pseudo-random number generator with an interface similar to rand() in C. the following functions:

rand () -- function of module rand
Returns an integer random number in the range [0 ... 32768).
choice (s) -- function of module rand
Returns a random element from the sequence (string, tuple or list) s.
srand (seed) -- function of module rand
Initializes the random number generator with the given integral seed. When the module is first imported, the random number is initialized with the current time.


Next: whrandom Prev: math Up: Miscellaneous Services Top: Top