librand.tex 868 Bytes
Newer Older
1
\section{Standard Module \sectcode{rand}}
Guido van Rossum's avatar
Guido van Rossum committed
2
\label{module-rand}
Guido van Rossum's avatar
Guido van Rossum committed
3
\stmodindex{rand}
4

Guido van Rossum's avatar
Guido van Rossum committed
5 6 7 8 9
The \code{rand} module simulates the C library's \code{rand()}
interface, though the results aren't necessarily compatible with any
given library's implementation.  While still supported for
compatibility, the \code{rand} module is now considered obsolete; if
possible, use the \code{whrandom} module instead.
10

11
\setindexsubitem{(in module rand)}
12

Guido van Rossum's avatar
Guido van Rossum committed
13 14
\begin{funcdesc}{choice}{seq}
Returns a random element from the sequence \var{seq}.
15 16
\end{funcdesc}

Guido van Rossum's avatar
Guido van Rossum committed
17 18
\begin{funcdesc}{rand}{}
Return a random integer between 0 and 32767, inclusive.
19 20 21
\end{funcdesc}

\begin{funcdesc}{srand}{seed}
Guido van Rossum's avatar
Guido van Rossum committed
22 23
Set a starting seed value for the random number generator; \var{seed}
can be an arbitrary integer. 
24
\end{funcdesc}
Guido van Rossum's avatar
Guido van Rossum committed
25

Guido van Rossum's avatar
Guido van Rossum committed
26 27 28 29
\begin{seealso}
\seemodule{whrandom}{the standard Python random number generator}
\end{seealso}