Skip to main content
main-content
Top

About this book

While other textbooks devote their pages to explaining introductory programming concepts, The Python Workbook focuses exclusively on exercises, following the philosophy that computer programming is a skill best learned through experience and practice. Designed to support and encourage hands-on learning about programming, this student-friendly work contains 174 exercises, spanning a variety of academic disciplines and everyday situations. Solutions to selected exercises are also provided, supported by brief annotations that explain the technique used to solve the problem, or highlight specific points of Python syntax. No background knowledge is required to solve the exercises, beyond the material covered in a typical introductory Python programming course.
Undergraduate students undergoing their first programming course and wishing to enhance their programming abilities will find the exercises and solutions provided in this book to be ideal for their needs.

Table of Contents

Exercises

Frontmatter

Chapter 1. Introduction to Programming Exercises

The exercises in this chapter are designed to help you develop your analysis skills by providing you with the opportunity to practice breaking small problems down into sequences of steps.
Ben Stephenson

Chapter 2. If Statement Exercises

The exercises in this chapter will require you to use decision making constructs so that your programs can handle a variety of different situations.
Ben Stephenson

Chapter 3. Loop Exercises

The exercises that appear in this chapter should all be completed using loops. Some of the exercises can be completed easily with both for loops and while loops. Other exercises are much better suited to one type of loop than the other.
Ben Stephenson

Chapter 4. Function Exercises

Functions allow a programmer to break a problem into pieces that can be reused.
Ben Stephenson

Chapter 5. List Exercises

Lists help programmers manage larger amounts of data by allowing several (or even many) values to be stored in one variable. This makes it practical to solve larger problems that involve many data values.
Ben Stephenson

Chapter 6. Dictionary Exercises

Dictionaries are another data structure that Python programmers can use to manage larger amounts of data.
Ben Stephenson

Chapter 7. File and Exception Exercises

Files allow us to work with data, without needing to enter it each time our program runs. Files also allow us to store results from our program in a more permanent manner.
Ben Stephenson

Chapter 8. Recursion Exercises

A recursive function is a function that calls itself. In this chapter, you will use recursive functions to solve a variety of problems.
Ben Stephenson

Solutions

Frontmatter

Chapter 9. Introduction to Programming Solutions

Solutions to selected exercises from Chap. 1.
Ben Stephenson

Chapter 10. If Statement Solutions

Solutions to selected exercises from Chap. 2.
Ben Stephenson

Chapter 11. Loop Solutions

Solutions to selected exercises from Chap. 3.
Ben Stephenson

Chapter 12. Function Solutions

Solutions to selected exercises from Chap. 4.
Ben Stephenson

Chapter 13. List Solutions

Solutions to selected exercises from Chap. 5.
Ben Stephenson

Chapter 14. Dictionary Solutions

Solutions to selected exercises from Chap. 6.
Ben Stephenson

Chapter 15. File and Exception Solutions

Solutions to selected exercises from Chap. 7.
Ben Stephenson

Chapter 16. Recursion Solutions

Solutions to selected exercises from Chap. 8.
Ben Stephenson
Additional information