mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Add punctuation mark; add some examples
This commit is contained in:
parent
f60eeb1738
commit
cbe801697b
1 changed files with 25 additions and 1 deletions
|
@ -236,7 +236,7 @@ these equations can be found in any statistics text.
|
|||
\var{beta} is the shape parameter.
|
||||
\end{funcdesc}
|
||||
|
||||
Alternative Generators
|
||||
Alternative Generators:
|
||||
|
||||
\begin{classdesc}{WichmannHill}{\optional{seed}}
|
||||
Class that implements the Wichmann-Hill algorithm as the core generator.
|
||||
|
@ -267,6 +267,30 @@ called.
|
|||
\versionadded{2.4}
|
||||
\end{classdesc}
|
||||
|
||||
Examples of basic usage:
|
||||
|
||||
\begin{verbatim}
|
||||
>>> random.random() # Random float x, 0.0 <= x < 1.0
|
||||
0.37444887175646646
|
||||
>>> random.uniform(1, 10) # Random float x, 1.0 <= x < 10.0
|
||||
1.1800146073117523
|
||||
>>> random.randint(1, 10) # Integer from 1 to 10, endpoints included
|
||||
7
|
||||
>>> random.randrange(0, 101, 2) # Even integer from 0 to 100
|
||||
26
|
||||
>>> random.choice('abcdefghij') # Choose a random element
|
||||
'c'
|
||||
|
||||
>>> items = [1, 2, 3, 4, 5, 6, 7]
|
||||
>>> random.shuffle(items)
|
||||
>>> items
|
||||
[7, 3, 2, 5, 6, 4, 1]
|
||||
|
||||
>>> random.sample([1, 2, 3, 4, 5], 3) # Choose 3 elements
|
||||
[4, 1, 5]
|
||||
|
||||
\end{verbatim}
|
||||
|
||||
\begin{seealso}
|
||||
\seetext{M. Matsumoto and T. Nishimura, ``Mersenne Twister: A
|
||||
623-dimensionally equidistributed uniform pseudorandom
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue