Page 1 of 1

Random numbers: the urandom module

Posted: Mon Dec 19, 2016 7:43 am
by pythoncoder
Questions have been raised regarding producing random numbers on platforms lacking the Pyboard's hardware random number generator.
[edited]
The module urandom supports a pseudorandom number generator via the getrandbits function. This returns an n-bit pseudorandom number. urandom.getrandbits(30) works in a similar way to pyb.rng().

Note that pyb.rng() returns hardware generated true random numbers, whereas the output of getrandbits is deterministic.