random — Easy Examples
Pseudo-random number generation, shuffling, and sampling
Getting started with random
Basic import and usage of the random module.
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.
Common random operations
Frequently used functions from the random module.
python
# More random examples import random print(f"random module loaded successfully") print(f"Location: {random.__name__}") print(f"Has {len(dir(random))} attributes")
These are the most commonly used features of the random module.
Want to try these examples interactively?
Open Easy Playground