Random Module
Random Module
and perform random selections. It's a part of Python's standard library and offers various
methods for randomness-related tasks. Here's an overview of commonly used functions in the
random module:
Generating Random Numbers:
1. random(): Returns a random float between 0 and 1.
import random
num = random.random()
randrange(start, stop, step): Returns a randomly selected element from the specified range.
num = random.randrange(1, 101, 2) # Random odd number between 1 and 100