Why do we use random.seed() in Python?


The seed() method of random module initializes the random number generator.

random.seed(a,b)

If a is omitted or None, the current system time is used. If randomness sources are provided by the operating system, they are used instead of the system time

If a is an int, it is used directly.

With version 2 (the default), a str, bytes, or bytearray object gets converted to an int and all of its bits are used.

With version 1 (provided for reproducing random sequences from older versions of Python), the algorithm for str and bytes generates a narrower range of seeds.


Updated on: 24-Jun-2020

197 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements