PyDocs

Nav

Numeric and Mathematical Modules

Random

random

class (source)
  • Random([seed])
Random number generator base class used by bound module functions.

Used to instantiate instances of Random to get generators that don't
share state.

Class Random can also be subclassed if you want to use a different basic
generator of your own devising: in that case, override the following
methods:  random(), seed(), getstate(), and setstate().
Optionally, implement a getrandbits() method so that randrange()
can cover arbitrarily large ranges.
Changed in 3.11
  • 3.11: Formerly the seed could be any hashable object. Now it is limited to: None, int, float, str, bytes, or bytearray.
Members of Random

g

getrandbits
getrandbits(k) -> x.
getstate
Return internal state; can be passed to setstate() later.

r

randbytes
Generate n random bytes.
random
random() -> x in the interval [0, 1).

s

seed
Initialize internal state from a seed.
setstate
Restore internal state from object returned by getstate().
0 Examples
No examples for random/Random.
See Also
No see-alsos for random/Random
0 Notes
No notes for Random