random
Stdlib — MathPython 2.0+Beginner
Pseudo-random number generation, shuffling, and sampling
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
- Dependencies
- None — Python Standard Library
- Install
Included with Python
Learn by Difficulty
Quick Example
python
import random print(random.randint(1, 10)) print(random.choice(["apple", "banana", "cherry"])) print(random.random()) print(random.sample(range(100), 5))
The random module is part of Python's standard library. Pseudo-random number generation, shuffling, and sampling.
Try in PlaygroundTags
stdlibmathrandomsamplingsimulation