Practice makes perfect Python!
The only way to master a skill is practice, practice, practice. That’s exactly what you’ll do in Python Workout, Second Edition! In this instantly-valuable book you’ll work through 50 carefully selected exercises that flex your programming muscles. This revised new edition covers the latest version of Python and adds updated content and diagrams.
In Python Workout, Second Edition you’ll find 50 exercises, including
• Working with text using strings
• Mastering dictionaries and sets
• Reading, writing, and manipulating files
• Functional programming with comprehensions
• Python modules and packages
• Creating iterable objects
To become a champion Python programmer you need to build mental muscle by putting your hands on the keyboard. Each carefully selected exercise in this unique book adds to your Python prowess—one important skill at a time. You’ll practice core Python language features and techniques that reinforce the programming patterns you’ll use every day and build the skills you need to troubleshoot your programs.
About the book
Python Workout, Second Edition hones your Python chops just like you would in the gym. Repetition of key skills builds muscle memory. New challenges increase your strength. Combining new and old techniques encourages flexibility. Expert Python coach Reuven Lerner guides you through each exercise with a detailed solution designed to give you a deeper fluency and understanding of Python.
About the reader
For readers with basic Python knowledge.
About the author
Reuven M. Lerner teaches Python and data science to companies around the world. He is the author of Python Workout and Pandas Workout.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A hands-on Python drill book that builds real fluency through 50 short, carefully sequenced exercises with detailed solutions. Best for readers who already know basic Python syntax and want to convert shaky knowledge into confident, everyday coding skill.
【Book Arc】
- **Opening (~0%–10%)**: Sets the philosophy—mastery comes from deliberate practice, not passive reading—and explains the book's structure: solve each exercise yourself, then compare against a worked solution, Python Tutor visualizations, and pytest tests. It also argues why leaning on AI before you can code undermines real learning.
- **Early (~10%–35%)**: Builds fundamentals through numeric and string exercises. You reimplement built-ins (like a custom `mysum`), explore parameter types and the splat operator, handle floating-point formatting with f-strings, and confront Python's mutable/immutable distinction—especially why strings can't be changed in place.
- **Middle (~35%–55%)**: Moves into collections—lists and tuples—covering when to use each, slicing behavior, out-of-bounds rules, and the practical consequences of mutability. Exercises push you to translate between data structures rather than just manipulate them.
- **Late (~55%–85%)**: Extends into dictionaries, sets, file reading/writing, and functional-style comprehensions, then into modules, packages, and building your own iterable objects. (Excerpts do not cover these chapters in detail.)
- **Ending (~85%–100%)**: Consolidates the full toolkit through the final exercises, reinforcing patterns you'll reuse daily and the troubleshooting instincts that come from having solved problems yourself. (Excerpts do not cover the closing chapters.)
【Key Takeaways】
- **Practice beats passive reading** (Opening): The book's core premise is that you only internalize Python by typing solutions, making mistakes, and reflecting—not by reading someone else's code.
- **AI can create the illusion of learning** (Early): The author warns that chatbots are useful brainstorming partners for experienced coders but can impede beginners by short-circuiting the struggle that builds real skill.
- **Parameter flexibility is a Python superpower** (Early): Exercises like `mysum` teach that Python doesn't overload functions by signature; instead you use `*args`, default values, and keyword parameters to handle varying inputs.
- **Immutability has real consequences** (Early–Middle): Strings, tuples, and numbers can't be changed in place, which affects dict keys, thread safety, and why methods on immutable types return new objects.
- **Lists and tuples serve different purposes** (Middle): Lists are for sequences of same-type items you'll modify; tuples are for fixed records of different-type fields—choosing wrong leads to awkward code.
- **Slicing is forgiving, indexing is not** (Middle): Out-of-range single indexes raise `IndexError`, but slices silently clamp to boundaries—a distinction that trips up beginners.
- **Reimplementing built-ins deepens understanding** (Early–Middle): Writing your own `sum` or Pig Latin translator forces you to think about iteration, data structures, and edge cases rather than calling a library.
- **Comprehensions and iterables are everyday tools** (Late): The book treats functional patterns and custom iterable objects as core fluency, not advanced trivia. (Excerpts do not cover these chapters in detail.)
【Reading Tips】
- **Solve before you look**: Attempt each exercise for at least ten minutes before reading the solution. The struggle is the point—skipping it wastes the book's main value.
- **Deep-read the "Working it out" sections**: These explain design decisions and Python semantics (like why assignment isn't an expression), which matter more than the final code.
- **Skim what you already know**: If numeric types and strings are solid, move faster through the early chapters and spend your time on collections, files, and iterables.
- **Use the companion resources**: Python Tutor links, downloadable code, and pytest tests let you verify your solution and see execution step by step—use them to debug your mental model, not just your syntax.
- **Keep a mistake log**: Note which exercises exposed gaps (e.g., mutability, slicing bounds) and revisit those concepts before moving on.
【Coverage Limits】
The excerpts cover the book's opening philosophy, early numeric/string material, and part of the collections chapters; later chapters on dictionaries, sets, files, comprehensions, modules, and iterables are only named, not detailed. This guide therefore describes the book's approach and early content more concretely than its later exercises.
Excerpt 1
ensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com> To my three children, who are also my best teachers— Atara Margalit, Shikma Bruria, and Amot...
be vibe-coding their own projects, rather than asking pro- grammers to do it for them, is unrealistic, to say the least. A second problem with this approach...
age time and number of runs.""" Look, it’s an infinite loop! It might seem weird to have number_of_runs = 0 “while True,” and it’s a very bad idea to have su...
ices from a tuple (from the Python Tutor) Staying in bounds When retrieving a single index, you can’t go beyond the bounds: s = 'abcd' s[5] Raises an IndexEr...
as an argument could be rewritten using lambda as follows: def run_func_with_world(f): return f('world') print(run_func_with_world(lambda name: f'Hello, {nam...
example, defaultdict(int) means that if we say rainfall[k] from collections import defaultdict and k isn’t in rainfall, the int function will execute rainfal...
ine across the : character, using the str.split method. str.split always returns a list of strings, although the length of that list depends on the number of...
from a CSV-style file into a JSON-formatted file. The JSON file will contain the equivalent of a list of Python tuples, with each tuple repre- senting one li...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Python Workout, Second Edition 200 ten-minute exercises (Reuven M. Lerner)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
Python Workout, Second Edition 200 ten-minute exercises (Reuven M. Lerner)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Python Workout, Second Edition 200 ten-minute exercises (Reuven M. Lerner)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment