Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 1 | \section{Standard Module \sectcode{rand}} |
| 2 | |
| 3 | \stmodindex{rand} This module implements a pseudo-random number |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame^] | 4 | generator with an interface similar to \code{rand()} in C\@. It defines |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 5 | the following functions: |
| 6 | |
| 7 | \renewcommand{\indexsubitem}{(in module rand)} |
| 8 | \begin{funcdesc}{rand}{} |
| 9 | Returns an integer random number in the range [0 ... 32768). |
| 10 | \end{funcdesc} |
| 11 | |
| 12 | \begin{funcdesc}{choice}{s} |
| 13 | Returns a random element from the sequence (string, tuple or list) |
| 14 | \var{s}. |
| 15 | \end{funcdesc} |
| 16 | |
| 17 | \begin{funcdesc}{srand}{seed} |
| 18 | Initializes the random number generator with the given integral seed. |
| 19 | When the module is first imported, the random number is initialized with |
| 20 | the current time. |
| 21 | \end{funcdesc} |