Random module
The random module is a Python standard-library module that provides pseudorandom-value generation, selection, sampling, and related utilities.
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.
Also covered in
What to know first
- PythonPython is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.
- integerAn integer is a whole-number mathematical value, including negative numbers, zero, and positive numbers, with no fractional part.
- listA list is an ordered collection of elements arranged in a sequence.
- stringA string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
Related concepts
- randinthas part · random.randint is a Python standard-library function that returns a pseudorandom integer between specified inclusive lower and upper bounds.
- random seedconfigured by · A random seed is a value that initializes a pseudorandom process and determines its subsequent sequence of outputs.
- C++produced by · C++ is a statically typed, general-purpose programming language that supports procedural, object-oriented, generic, and low-level systems programming.
- stateuses · State is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
Questions about random module
What is random module?
The random module is a Python standard-library module that provides pseudorandom-value generation, selection, sampling, and related utilities.
Which Manning books explain random module?
Python Workout: 50 ten-minute exercises, Python Workout, Second Edition, Get Programming: Learn to code with Python and Tiny Python Projects: Learn coding and testing with puzzles and games.
What should I know before learning random module?
Manning books that teach random module usually introduce Python, integer, list and string first.
What are the parts of random module?
Random module includes randint and random.choice.
What is random module also called?
Random module is also called random library.
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.



