random.setstate

Full name
random.setstate
Library
random
Syntax

random.setstate(state)

Description

The random.setstate function restores the state of the random number generator.

Parameters
  • state: State of the random number generator. It must have been obtained by previously executing the random.getstate function.
Result

The random.setstate function does not return a value.

Examples

We can get the state of the random number generator, store it in the variable s and restore it with the following code:

s = random.getstate()
random.setstate(s)
Submitted by admin on Sun, 02/21/2021 - 09:18