Home >>Python Random Module >Python Random seed() Method

Python Random seed() Method

Python Random seed() Method

Python Random seed() method in python is used to set the integer starting value used in random number generator and by using seed() method you can customize the start number of the random number generator.

Syntax:
random.seed(a, version)

Parameter Values

Parameter Description
a It is Optional. The seed value needed to generate the next random number and its default value is None
version Its default value is 2.
Here is an example of Python Random seed() Method:

import random
random.seed(8)
print(random.random())

Output:
0.2267058593810488
Example 2:

import random
random.seed(5)
print(random.random())
random.seed(12)
print(random.random())

Output:
0.6229016948897019
0.4745706786885481

No Sidebar ads