Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
communitycreator

How to use the random getstate() method in Python

Onyejiaku Theophilus Chidalu

Overview

The random.getstate() method in Python is simply used to get the present or current state of the pseudo-random number generator.

Syntax

random.getstate()

Parameter value

The random.getstate() method does not take any parameter value.

Example

Let’s return the current state of the pseudo-random number generator.

import random

print(random.getstate())

Explanation

  • Line 1: we imported the random module.
  • Line 3: we printed the current state of our pseudo-random number generator using the random.getstate() method.

RELATED TAGS

python
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu
RELATED COURSES

View all Courses

Keep Exploring