blob: 06605661caaeffeb48b3f08d37045a0f958d684e [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
Guido van Rossum571391b1997-04-03 22:41:49 +000011\begin{funcdesc}{choice}{seq}
12Returns a random element from the sequence \var{seq}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000013\end{funcdesc}
14
Guido van Rossum571391b1997-04-03 22:41:49 +000015\begin{funcdesc}{rand}{}
16Return a random integer between 0 and 32767, inclusive.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000017\end{funcdesc}
18
19\begin{funcdesc}{srand}{seed}
Guido van Rossum571391b1997-04-03 22:41:49 +000020Set a starting seed value for the random number generator; \var{seed}
21can be an arbitrary integer.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000022\end{funcdesc}
Guido van Rossum571391b1997-04-03 22:41:49 +000023
Guido van Rossume47da0a1997-07-17 16:34:52 +000024\begin{seealso}
25\seemodule{whrandom}{the standard Python random number generator}
26\end{seealso}
27