Random : Random Seed Getstate Setstate Getrandbits
Random : Random Seed Getstate Setstate Getrandbits
Bookkeeping functions
random.seed(a=None, version=2)
Initialize the random number generator.
random.getstate()
Return an object capturing the current internal state of the
generator. This object can be passed to setstate() to
restore the state.
random.setstate(state)
state should have been obtained from a previous call
to getstate(), and setstate() restores the internal state of
the generator to what it was at the time getstate() was
called.
random.randint(a, b)
Return a random integer N such that a <= N <= b. Alias
for randrange(a, b+1).
random.getrandbits(k)
Returns a non-negative Python integer with k random bits.
This method is supplied with the MersenneTwister generator
and some other generators may also provide it as an optional
part of the API. When
available, getrandbits() enables randrange() to handle
arbitrarily large ranges.
random.shuffle(x[, random])
Shuffle the sequence x in place.
random.sample(population, k, *, counts=None)
Return a k length list of unique elements chosen from the
population sequence or set. Used for random sampling
without replacement.
Returns a new list containing elements from the population
while leaving the original population unchanged. The
resulting list is in selection order so that all sub-slices will
also be valid random samples. This allows raffle winners (the
sample) to be partitioned into grand prize and second place
winners (the subslices).
random.random()
Return the next random floating point number in the range
[0.0, 1.0).
random.uniform(a, b)¶