Numerical Standard Library Modules
random — standard library module
Pseudorandom selection, shuffling and distribution sampling. Use a separate Random instance for independent state and a seed for reproducibility within supported guarantees. Not for passwords or cryptographic secrets; use secrets instead.
Formal Syntax & Structure
python syntaxpython
import randomReturn Value
Not applicable
Import binds a module name; individual APIs determine results.
Working Example
Example Snippetpython
from random import Randoma = Random(42)b = Random(42)print(a.sample(range(20), 3) == b.sample(range(20), 3))