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

PythonServer Side ProgrammingProgramming

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.


raja
Published on 05-Mar-2018 05:30:01
Advertisements