random.seed

Full name
random.seed
Library
random
Syntax

random.seed(a = None, version = v)

Description

The random.seed function initializes the random number generator.

Parameters
  • a: Seed to use. Since version 3.9 it can only take the value None (default value) or be of type int, float, str, bytes or bytearray. If this argument takes the value None, the seed is obtained from the system clock.
  • version: Code version to use. It can take the values 1 or 2 (default value). Version 1 is offered to ensure compatibility with older code.
Result

The random.seed function does not return any results.

Examples

We can initialize the random number generator with seed 18 and generate a random integer from a uniform distribution with the following code:

random.seed(18)
random.randint(0, 9)
2
Submitted by admin on Sat, 02/20/2021 - 08:08