Like its CPython cousin, CircuitPython’s random seeds itself on first use with a true random from os.urandom() when available or the uptime otherwise. Once seeded, it will be deterministic, which is why its bad for cryptography.
Numbers from this module are not cryptographically strong! Use
os.urandom directly for true randomness.
seed(seed: int) → None¶
Sets the starting seed of the random number generation. Further calls to
randomwill return deterministic results afterwards.
randrange(stop: Tuple[int, int, int]) → int¶
Returns a randomly selected integer from
range(start, stop, step).
randint(a: int, b: int) → int¶
Returns a randomly selected integer between a and b inclusive. Equivalent to
randrange(a, b + 1, 1)
choice(seq: Sequence[_T]) → _T¶
Returns a randomly selected element from the given sequence. Raises IndexError when the sequence is empty.