The Python Workbook

A Brief Introduction with Exercises and Solutions

  • Ben Stephenson

Part of the Texts in Computer Science book series (TCS)

Table of contents

  1. Front Matter
    Pages i-x
  2. Exercises

    1. Front Matter
      Pages 1-1
    2. Ben Stephenson
      Pages 3-22
    3. Ben Stephenson
      Pages 23-42
    4. Ben Stephenson
      Pages 43-57
    5. Ben Stephenson
      Pages 59-73
    6. Ben Stephenson
      Pages 75-95
    7. Ben Stephenson
      Pages 97-107
    8. Ben Stephenson
      Pages 109-126
    9. Ben Stephenson
      Pages 127-139
  3. Solutions

    1. Front Matter
      Pages 141-141
    2. Ben Stephenson
      Pages 151-160
    3. Ben Stephenson
      Pages 161-167
    4. Ben Stephenson
      Pages 169-181
    5. Ben Stephenson
      Pages 183-192
    6. Ben Stephenson
      Pages 193-197
    7. Ben Stephenson
      Pages 199-208
    8. Ben Stephenson
      Pages 209-213
  4. Back Matter
    Pages 215-219

About this book


This student-friendly textbook encourages the development of programming skills through active practice by focusing on exercises that support hands-on learning. The Python Workbook provides a compendium of 186 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 a specific point of Python syntax.

This enhanced new edition has been thoroughly updated and expanded with additional exercises, along with concise introductions that outline the core concepts needed to solve them. The exercises and solutions require no prior background knowledge, beyond the material covered in a typical introductory Python programming course.


  • Uses an accessible writing style and easy-to-follow structure
  • Includes a mixture of classic exercises from the fields of computer science and mathematics, along with exercises that connect to other academic disciplines
  • Presents the solutions to approximately half of the exercises
  • Provides annotations alongside the solutions, which explain the approach taken to solve the problem and relevant aspects of Python syntax
  • Offers a variety of exercises of different lengths and difficulties
  • Contains exercises that encourage the development of programming skills using if statements, loops, basic functions, lists, dictionaries, files, and recursive functions

Undergraduate students enrolled in 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.

Dr. Ben Stephenson is a Teaching Professor in the Department of Computer Science at the University of Calgary, AB, Canada. His other publications include the Springer textbook Fundamentals of Discrete Math for Computer Science: A Problem-Solving Primer.


Introductory Computer Science Multidisciplinary Studies Programming Python Software Engineering

Authors and affiliations

  • Ben Stephenson
    • 1
  1. 1.Department of Computer ScienceUniversity of CalgaryCalgaryCanada

Bibliographic information

Industry Sectors
IT & Software
Consumer Packaged Goods
Finance, Business & Banking
Oil, Gas & Geosciences