random
Pseudo-random numbers for simulations and games (not for security).
Beginner
import random
random.seed(42) # reproducible results
random.random(), random.randint(1, 6)
random.choice(parts), random.sample(range(100), 5), random.shuffle(deck)
random.gauss(0, 1)
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.