random.getstate

Full name
random.getstate
Library
random
Syntax

random.getstate()

Description

The random.getstate function returns an object containing the current state of the random number generator. This object can be passed as an argument to the random.setstate function to restore its state.

Parameters

The random.getstate function takes no arguments.

Result

The random.getstate function returns a tuple.

Examples

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

s = random.getstate()

We can verify that this object is a tuple:

type(s)
tuple

...as well as the number of elements it contains:

len(s)
3
Submitted by admin on Sun, 02/21/2021 - 09:12