Worked Python exercises
From time to time, people ask me for solutions to the exercises for my Python book. I don't have them available, but I do have this set of 271 exercises and solutions.I put all of this together very quickly, so there are likely errors. Please let me know of any you find, and I'll fix them.
Exercises and Solutions
- All the exercises
- Text files (especially needed for Chapter 12)
- Chapter 1 solutions (Getting Started)
- Chapter 2 solutions (For Loops)
- Chapter 3 solutions (Numbers)
- Chapter 4 solutions (If Statements)
- Chapter 5 solutions (Miscellaneous Topics I)
- Chapter 6 solutions (Strings)
- Chapter 7 solutions (Lists)
- Chapter 8 solutions (More with Lists)
- Chapter 9 solutions (While Loops)
- Chapter 10 solutions (Miscellaneous Topics II)
- Chapter 11 solutions (Dictionaries)
- Chapter 12 solutions (Text Files)
- Chapter 13 solutions (Functions)
- Chapter 14 solutions (Object-Oriented Programming)
Note: In the book, the +=
operator is not introduced until Chapter 10, but I used it in a lot of the solutions for earlier chapters. An expression like total += 10
is shorthand for total = total + 10
.