Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 1 | \section{Standard Module \sectcode{rand}} |
Guido van Rossum | e47da0a | 1997-07-17 16:34:52 +0000 | [diff] [blame] | 2 | \label{module-rand} |
Guido van Rossum | 571391b | 1997-04-03 22:41:49 +0000 | [diff] [blame] | 3 | \stmodindex{rand} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 4 | |
Guido van Rossum | 571391b | 1997-04-03 22:41:49 +0000 | [diff] [blame] | 5 | The \code{rand} module simulates the C library's \code{rand()} |
| 6 | interface, though the results aren't necessarily compatible with any |
| 7 | given library's implementation. While still supported for |
| 8 | compatibility, the \code{rand} module is now considered obsolete; if |
| 9 | possible, use the \code{whrandom} module instead. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 10 | |
Guido van Rossum | 571391b | 1997-04-03 22:41:49 +0000 | [diff] [blame] | 11 | \begin{funcdesc}{choice}{seq} |
| 12 | Returns a random element from the sequence \var{seq}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 13 | \end{funcdesc} |
| 14 | |
Guido van Rossum | 571391b | 1997-04-03 22:41:49 +0000 | [diff] [blame] | 15 | \begin{funcdesc}{rand}{} |
| 16 | Return a random integer between 0 and 32767, inclusive. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 17 | \end{funcdesc} |
| 18 | |
| 19 | \begin{funcdesc}{srand}{seed} |
Guido van Rossum | 571391b | 1997-04-03 22:41:49 +0000 | [diff] [blame] | 20 | Set a starting seed value for the random number generator; \var{seed} |
| 21 | can be an arbitrary integer. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 22 | \end{funcdesc} |
Guido van Rossum | 571391b | 1997-04-03 22:41:49 +0000 | [diff] [blame] | 23 | |
Guido van Rossum | e47da0a | 1997-07-17 16:34:52 +0000 | [diff] [blame] | 24 | \begin{seealso} |
| 25 | \seemodule{whrandom}{the standard Python random number generator} |
| 26 | \end{seealso} |
| 27 | |