Index / 001 EN
Python Crash Course: A Hands-On, Project-Based Introduction to Programming cover

Computer Science

Computer Science

Python Crash Course: A Hands-On, Project-Based Introduction to Programming

Eric Matthes

A practical first book on programming in Python, written by a former school teacher for readers with no prior experience. The first half teaches core language features with short exercises; the second half applies them in three larger projects: a simple arcade game, data visualizations, and a web application built with Django.

Prerequisites: None beyond basic computer use; no previous programming experience is assumed.

Difficulty Level
Beginner
Academic Level
Undergraduate
pythonprogramming fundamentalsprojectsbeginner programmingTextbook

01 / Reading Guide

Reading Guide

Citation

Matthes, E. (2022). Python Crash Course: A Hands-On, Project-Based Introduction to Programming (3rd ed.). No Starch Press.

Chapter Summary

The third edition has twenty chapters in two parts, an afterword and five appendices, in a little over 500 pages. Part I (Chapters 1–11) teaches the language; Part II (Chapters 12–20) uses it in three projects: an arcade game, data visualisations and a web application. Every topic is followed by short "Try It Yourself" exercises, numbered by chapter. According to the author's notes on the edition, the book uses Python 3.11, recommends VS Code as an editor, works with files through the pathlib module, and teaches testing with pytest instead of the standard library's unittest; the projects use current versions of their libraries, including Django 4.1 and Bootstrap 5.

Chapter 1: Getting Started

Setting up Python and the VS Code editor on Windows, macOS or Linux, running a first "hello world" program, troubleshooting installation, and running programs from a terminal.

Chapter 2: Variables and Simple Data Types

What happens when a program runs, variables (presented as labels for values), strings and string methods including the newer prefix-removal methods, integers and floats, constants, comments, and the Zen of Python. Avoiding common errors is built into each topic, and the chapter shows Python's improved error messages.

Chapters 3–4: Introducing Lists; Working with Lists

Creating, indexing, modifying and sorting lists; then looping with for, avoiding indentation errors, numerical lists with range() and list comprehensions, slicing and copying, tuples, and a first look at code style through PEP 8.

Chapter 5: if Statements

Conditional tests, if, if-else and if-elif-else chains, using conditionals with lists, and styling if statements.

Chapter 6: Dictionaries

Working with key-value pairs, looping through dictionaries, and nesting lists and dictionaries inside one another.

Chapter 7: User Input and while Loops

The input() function, while loops with flags, break and continue, and using while loops to process lists and dictionaries.

Chapter 8: Functions

Defining functions, positional and keyword arguments with defaults, return values, passing lists, arbitrary numbers of arguments, storing functions in modules and import styles.

Chapter 9: Classes

Creating classes and instances, modifying attributes, inheritance and overriding methods, instances as attributes, importing classes from modules, the standard library, and styling classes.

Chapter 10: Files and Exceptions

Reading and writing files with pathlib, handling exceptions with try-except-else, analysing text from several files, storing data with JSON, and refactoring.

Chapter 11: Testing Your Code

Installing pytest with pip, writing passing and failing tests for a function, a variety of assertions, testing a class and using fixtures.

Chapters 12–14: A Ship That Fires Bullets; Aliens!; Scoring

The Alien Invasion project with Pygame, inspired by Space Invaders. Readers plan the game, create a window and a ship that responds to keys, fire bullets, build and move a fleet of aliens, detect collisions, end the game, then add a Play button, increasing speed, a scoreboard, high scores, levels and remaining ships. Refactoring into helper methods is practised throughout.

Chapters 15–17: Generating Data; Downloading Data; Working with APIs

The data visualisation project. Chapter 15 plots with Matplotlib (line graphs, scatter plots, random walks) and simulates dice rolls with Plotly. Chapter 16 reads weather data from CSV files and earthquake data in GeoJSON format to draw a world map. Chapter 17 requests data from the GitHub API with the Requests library, visualises the most popular repositories, and introduces the Hacker News API.

Chapters 18–20: Getting Started with Django; User Accounts; Styling and Deploying an App

The web application project, a "Learning Log". Chapter 18 sets up a virtual environment and a Django project, defines models, uses the admin site and builds pages with templates. Chapter 19 adds forms for entering data, user registration and login, and restricts each user to their own data. Chapter 20 styles the site with Bootstrap and deploys it to the Platform.sh hosting service using Git.

Afterword and Appendices A–E

The appendices cover installation and troubleshooting (with lists of Python keywords and built-in functions), text editors and IDEs, getting help, using Git for version control, and troubleshooting deployments.

Key Concepts

Part I: Basics (Chapters 1–11)

  • Variables and data types: names that refer to values such as strings, integers and floats.
  • Lists, tuples and dictionaries: Python's core collections, with loops, slicing and comprehensions.
  • Control flow: conditional tests, if-elif-else chains and while loops.
  • Functions and modules: reusable blocks of code with flexible arguments, organised into files that can be imported.
  • Classes and inheritance: modelling real-world things as objects with attributes and methods.
  • Files, exceptions and JSON: reading and writing data, handling errors gracefully, and storing data between runs.
  • Automated testing: checking code with pytest assertions and fixtures.

Part II: Projects (Chapters 12–20)

  • Game loop and sprites: the event-driven structure of a Pygame game.
  • Data visualisation: turning generated, downloaded and API data into charts and maps with Matplotlib and Plotly.
  • Web APIs: requesting structured data from online services.
  • Models, views and templates: the structure of a Django web application.
  • User authentication and deployment: accounts, access restrictions, and putting an application online.

Critical Analysis

Strengths

  • Basics and projects in one book. Serdar Yegulalp in InfoWorld observed that many books offer either Python basics or projects, whereas this one delivers both. The three projects use real libraries (Pygame, Matplotlib, Plotly, Requests, Django) and end in a finished game, interactive charts and a deployed web site.
  • Constant practice. The detailed contents list 186 numbered exercises, several after each major topic, many of them building on earlier ones (a guest list grows across Chapter 3; a sideways shooter grows across Chapters 12–14).
  • Professional habits early. Style guidance from PEP 8, refactoring, testing with pytest, virtual environments and Git appear in a beginners' book. Error handling is taught alongside each feature, not left to the end.
  • Kept current and supported. The third edition updates the language version, editor and libraries, and the author's website provides source code, cheat sheets, solutions to exercises and updates for each printing.

Limitations

  • Programming practice, not computer science. The book teaches how to write working Python programs; it does not cover algorithms, data structures beyond Python's built-ins, complexity or theory of computation.
  • Deployment instructions date quickly. Chapter 20 deploys to Platform.sh. The author's website now explains that the company has rebranded and changed its approach, no longer recommends it for learners, and gives replacement instructions for another host. Readers should follow the online version.
  • Depth over breadth in the projects. Each project covers one library in detail; students wanting a broader survey of Python's ecosystem, or more advanced language features, will need further reading.

Where It Fits in the Course

This is the most hands-on, project-led first book in the introductory programming course. Allen Downey's Think Python also uses Python but frames programming as a way of thinking like a computer scientist, with more attention to concepts and problem solving; it suits readers who want explanation of why programs work as well as how to write them. Felleisen and colleagues' How to Design Programs teaches a systematic design method with teaching languages in DrRacket rather than a mainstream language. John Guttag's Introduction to Computation and Programming Using Python goes further into computational thinking, modelling and data analysis and is a natural next step after Part I.

Abelson and Sussman's Structure and Interpretation of Computer Programs is a classic study of abstraction and interpreters, and Kernighan and Ritchie's The C Programming Language teaches C with pointers and memory; both are more demanding and suit students who have already programmed. A common path is to learn the language with Matthes, then read Downey or Guttag for concepts, and move to C or SICP in later courses.

How to Use This Book

The book suits complete beginners of any age and discipline, students whose course text is more theoretical and who want practice building things, and programmers from other languages who want a fast route into Python. No previous programming is assumed.

  • Core: Part I in order. Type the examples yourself and do every "Try It Yourself" exercise before moving on. Chapters 8–10 deserve the most time; Chapter 11 on testing is worth doing even if the course does not require it.
  • Projects: choose by interest. Each project depends on Part I rather than on the other projects. The game teaches classes and program structure, the visualisation chapters suit students in science or data-heavy fields, and the web project is the longest and most demanding.
  • Appendices: keep A (installation and troubleshooting) and C (getting help) at hand, and use D to put your own projects under version control with Git.

Download the source code and check the author's website for updates for your printing, especially before attempting deployment in Chapter 20. After finishing, extend one project substantially on your own: the habit of designing and debugging an unguided program is what turns the book's exercises into programming skill.