Python Workout
50 ten-minute exercises
Reuven M. Lerner
  • July 2020
  • ISBN 9781617295508
  • 248 pages
  • printed in black & white

Whether you’re a Python novice or, like me, have been away from the language for a while, this book is a great way to build strength with Python.

Mark Elston, Advantest America
The only way to master a skill is to practice. In Python Workout, author Reuven M. Lerner guides you through 50 carefully selected exercises that invite you to flex your programming muscles. As you take on each new challenge, you'll build programming skill and confidence. The thorough explanations help you lock in what you've learned and apply it to your own projects. Along the way, Python Workout provides over four hours of video instruction walking you through the solutions to each exercise and dozens of additional exercises for you to try on your own.

About the Technology

To become a champion Python programmer you need to work out, building mental muscle with your hands on the keyboard. Each carefully selected exercise in this unique book adds to your Python prowess—one important skill at a time.

About the book

Python Workout presents 50 exercises that focus on key Python 3 features. In it, expert Python coach Reuven Lerner guides you through a series of small projects, practicing the skills you need to tackle everyday tasks. You'll appreciate the clear explanations of each technique, and you can watch Reuven solve each exercise in the accompanying videos.
Table of Contents detailed table of contents

1 Numeric types

Useful references

Exercise 1 — Number guessing game

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 2 — Summing numbers

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 3 — Run timing

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 4 — Hexadecimal output

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

2 Strings

Useful references

Exercise 5 — Pig Latin

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 6 — Pig Latin sentence

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 7 — Ubbi Dubbi

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 8 — Sorting a string

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

3 Lists and tuples

Exercise 9 — First-last

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 10 — Summing anything

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 11 — Alphabetizing names

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 12 — Word with most repeated letters

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 13 — Printing tuple records

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

4 Dictionaries and sets

Hashing and dicts

Sets

Exercise 14 — Restaurant

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 15 — Rainfall

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 16 — Dictdiff

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 17 — How many different numbers?

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

5 Files

Exercise 18 — Final line

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 19 — /etc/passwd to dict

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 20 — Word count

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 21 — Longest word per file

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 22 — Reading and writing CSV

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 23 — JSON

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 24 — Reverse lines

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

6 Functions

Exercise 25 — XML generator

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 26 — Prefix notation calculator

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 27 — Password generator

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

7 Functional programming with comprehensions

Exercise 28 — Join numbers

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 29 — Add numbers

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 30 — Flatten a list

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 31 — Pig Latin translation of a file

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 32 — Flip a dict

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 33 — Transform values

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 34 — (Almost) supervocalic words

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 35a — Gematria, part 1

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 35b — Gematria, part 2

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

8 Modules and packages

Exercise 36 — Sales tax

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 37 — Menu

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

9 Objects

Exercise 38 — Ice cream scoop

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 39 — Ice cream bowl

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 40 — Bowl limits

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 41 — A bigger bowl

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 42 — FlexibleDict

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 43 — Animals

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 44 — Cages

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 45 — Zoo

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

10 Iterators and generators

Exercise 46 — MyEnumerate

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 47 — Circle

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 48 — All lines, all files

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 49 — Elapsed since

Working it out

Solution

Screencast solution

Beyond the exercise

Exercise 50 — MyChain

Working it out

Solution

Screencast solution

Beyond the exercise

Summary

Conclusion

What's inside

  • 50 hands-on exercises and solutions
  • Coverage of all Python data types
  • Dozens more bonus exercises for extra practice

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.

placing your order...

Don't refresh or navigate away from the page.
print book $29.99 $59.99 pBook + eBook + liveBook
Additional shipping charges may apply
Python Workout (print book) added to cart
continue shopping
go to cart

eBook $47.99 3 formats + liveBook
Python Workout (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.
customers also reading

This book 1° 2° 3°

FREE domestic shipping on three or more pBooks