Random Library Guide | CMSC 105 Elementary Programming - Fall 2024

Python Random Library Guide

The Python random module provides tools for generating random numbers, selecting random elements, and more. This guide covers the most commonly used functions.

For more information, check the Python random documentation.


1. random()


2. randint(a, b)


3. choice(seq)


4. choices(seq, k)


5. shuffle(seq)


6. sample(seq, k)


7. uniform(a, b)


8. randrange(start, stop, step)


9. seed(value)


10. Generating Random Booleans