liveBook · Manning

Random module

The random module is a Python standard-library module that provides pseudorandom-value generation, selection, sampling, and related utilities.

How 4 Manning books explain it

Python Workout: 50 ten-minute exercises

Python's standard-library module for generating pseudorandom values and selecting elements.

How it is used
Uses random selection to drive guessing games and generate configurable passwords.
How deep it goes
Explains randint and choice through complete exercises, including inclusive bounds, but does not detail module internals.
Examples
Demonstrates a number-guessing game, randint range selection, and password generation with alphabetic or symbolic characters.
What you can do after
Apply it via randint and choice to build guessing games and configurable password generators.

Read how Python Workout: 50 ten-minute exercises explains random module →

Python Workout, Second Edition

The random module is Python's standard-library module for generating pseudorandom values and making pseudorandom selections.

How it is used
Generates random integers and supports selection tasks such as an interactive number-guessing game.
How deep it goes
Explains randint calls, inclusive bounds, and sequence selection, but does not discuss pseudorandom algorithms or seeding.
Examples
Uses a number-guessing game with a hidden integer from 0 through 100 and high, low, or correct feedback.
What you can do after
Apply it via Python's random module to generate bounded integers and choose random values.

Read how Python Workout, Second Edition explains random module →

Get Programming: Learn to code with Python

random is a Python standard-library module that provides facilities for generating pseudorandom values and making random selections.

How it is used
Supports unpredictable selections, number generation, list rearrangement, games of chance, and repeatable testing.
How deep it goes
Explains imports, core functions, probability ranges, sampling, and seeding, but stops short of generator internals.
Examples
Demonstrates person selection, nonrepeating samples, integer ranges, rock-paper-scissors, and seeded output.
What you can do after
Build random selections and chance-based programs, then diagnose inconsistent tests with a seed.

Read how Get Programming: Learn to code with Python explains random module →

Tiny Python Projects: Learn coding and testing with puzzles and games

random is Python's standard-library module for generating pseudo-random values and performing random selections.

How it is used
Generates selections and random transformations in command-line exercises, while seeds make expected test output reproducible.
How deep it goes
Explains pseudo-random state, hashable seeds, selection functions, and in-place shuffling, but does not develop generator internals.
Examples
Demonstrates random insults, ransom-note capitalization, workout selection, and shuffled word middles.
What you can do after
Apply it via Python functions to select items, transform text, shuffle lists, and reproduce results with controlled seeds.

Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains random module →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.