blob: a48ea221d29c2891e3a2cabafeeb5e503cefd196 [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Standard Module \module{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
Guido van Rossum571391b1997-04-03 22:41:49 +000012\begin{funcdesc}{choice}{seq}
13Returns a random element from the sequence \var{seq}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000014\end{funcdesc}
15
Guido van Rossum571391b1997-04-03 22:41:49 +000016\begin{funcdesc}{rand}{}
17Return a random integer between 0 and 32767, inclusive.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000018\end{funcdesc}
19
20\begin{funcdesc}{srand}{seed}
Guido van Rossum571391b1997-04-03 22:41:49 +000021Set a starting seed value for the random number generator; \var{seed}
22can be an arbitrary integer.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000023\end{funcdesc}
Guido van Rossum571391b1997-04-03 22:41:49 +000024
Guido van Rossume47da0a1997-07-17 16:34:52 +000025\begin{seealso}
26\seemodule{whrandom}{the standard Python random number generator}
27\end{seealso}
28