blob: 4ba5f17224f47d6bc18ac302b2d2dbf8d83384b0 [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Standard Module \sectcode{rand}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-rand}
Guido van Rossum571391b1997-04-03 22:41:49 +00003\stmodindex{rand}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00004
Guido van Rossum571391b1997-04-03 22:41:49 +00005The \code{rand} module simulates the C library's \code{rand()}
6interface, though the results aren't necessarily compatible with any
7given library's implementation. While still supported for
8compatibility, the \code{rand} module is now considered obsolete; if
9possible, use the \code{whrandom} module instead.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000010
Fred Drake7730cc01997-11-30 05:23:47 +000011\renewcommand{\indexsubitem}{(in module rand)}
12
Guido van Rossum571391b1997-04-03 22:41:49 +000013\begin{funcdesc}{choice}{seq}
14Returns a random element from the sequence \var{seq}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000015\end{funcdesc}
16
Guido van Rossum571391b1997-04-03 22:41:49 +000017\begin{funcdesc}{rand}{}
18Return a random integer between 0 and 32767, inclusive.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000019\end{funcdesc}
20
21\begin{funcdesc}{srand}{seed}
Guido van Rossum571391b1997-04-03 22:41:49 +000022Set a starting seed value for the random number generator; \var{seed}
23can be an arbitrary integer.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000024\end{funcdesc}
Guido van Rossum571391b1997-04-03 22:41:49 +000025
Guido van Rossume47da0a1997-07-17 16:34:52 +000026\begin{seealso}
27\seemodule{whrandom}{the standard Python random number generator}
28\end{seealso}
29