Think Python: How to Think Like a Computer Scientist (3rd edition) by Allen B. Downey, adapted for self-directed learning with AI pair-programming assistants.
- Adapter: Titus Klinge
- Original author: Allen B. Downey
- Upstream source: AllenDowney/ThinkPython
- Text license: CC BY-NC-SA 4.0 — see LICENSE.md
- Code license: MIT — see LICENSE.md
This course is designed for self-directed learning with GitHub Copilot (or a compatible AI coding assistant) in VS Code.
- Open this repository in VS Code
- Start at Chapter 1 (Setup) and work through chapters in order
- Read each chapter's markdown reading file
- Practice in the VS Code Python REPL, by running the chapter's example programs in its
examples/folder, or by writing your own scripts - Ask Copilot for help with exercises — each chapter has tailored coaching instructions
No Jupyter notebooks required. No build step. Just read, code, and practice.
Tip: Code exercises live in
exercises/folders as scaffold files you can run to check your work — most include doctests, a few are visual turtle programs or runnable scripts. Each chapter'sexamples/folder has practical mini-programs built only from that chapter's concepts — run them to see the pieces fit together. They never contain exercise solutions; ask your AI assistant for hints, not answers. Each chapter's reading opens with a short table of contents and closes with links to its exercises, examples, and the next chapter.
# 1. Clone and open the repository in VS Code
git clone https://github.com/tklinge/ThinkPython.git && code ThinkPython# 2. From the chapter folder, run a worked example (Chapter 4: Functions)
cd ThinkPython/chapter04 && python3 examples/tour_poster.py# 3. Run that chapter's worked-example doctests — you should see "Test passed."
python3 -m doctest examples/merch_stand.py -v | tail -3# 4. Now run an exercise scaffold. Its doctests are the spec for code you
# haven't written yet, so they fail — that red is the thing to fix.
python3 -m doctest exercises/ex01_print_right.py | head -5- Open
chapter04/exercises/ex01_print_right.pyin the editor, and in Copilot Chat (with the#filereference attached) ask: "Give me a hint for exercise 1, not the solution." The chapter's coaching instructions tell the assistant to make you predict, run, and explain before it gives anything away.
The interesting part of this repository is not the markdown — it is the arrangement that keeps an AI assistant from doing the exercise for you:
- Reference solutions are agent-only. Each chapter's
.github/instructions/chapterXX.instructions.mdcarries a## Reference Solutionssection. The coach checks your work against it and never shows or pastes it. - Doctests are the executable spec. The verdict on your code comes from
doctest, not from a model's opinion. Scaffold doctests are written so that a correct solution passes them. - Coaching flows are Socratic and per-exercise. Each instructions file maps exercises 1:1 to the reading's numbered exercises, with
File:refs, and escalates to hints only when you ask. - Concept boundaries. Chapter N's examples use only constructs taught through chapter N — no f-strings before chapter 14, no
dictbefore chapter 11 — so the assistant cannot solve your exercise in vocabulary you have not met yet. - Examples never contain exercise solutions. They are worked programs in the chapter's own vocabulary, safe to open.
These are prompt-level guardrails, not enforced sandboxing: they shape what a well-behaved assistant does, and a determined learner can still ask for the answer. The scaffolds make the honest path the easy one.
This adaptation was drafted with an AI coding assistant working under human direction, and the human is the author of record for the pedagogical decisions: what a chapter teaches, which exercise goes where, how much the coach is allowed to give away. The model's drafts were accepted, rewritten, or thrown away to match those decisions, not the other way round.
The toolchain was pi, a coding agent. The earliest passes ran it directly; later work — including the pass that added this paragraph — ran on the PiDelegation conductor/worker extension, where a conductor model plans a pass and dispatches bounded tasks to worker models that report back with evidence. PiDelegation began in August 2026, two months into this adaptation, and grew against this book's ongoing editorial work rather than a demo — which makes this repository its testbed in the plainest sense: not a project built to show the tool off, but the real work the tool had to supervise.
The models are open-weight Qwen 3.8 checkpoints served locally on self-hosted
hardware, with no cloud API in the loop. No single model wrote this, and the log
says so: every commit of this edition's own work carries a Co-Authored-By:
trailer naming the model that did that commit's work — most of the adaptation was
done by Qwen 3.8 27b, recent passes by Qwen 3.8 Flash Next — while the
commits inherited from upstream carry no such trailer, because they are Downey's.
Count them yourself rather than trusting any number this file might quote:
git log --format=%b | grep '^Co-Authored-By:' | sort | uniq -c.
The division of labor: the assistant drafted most of the edition's own material —
the added sections of the readings, the example programs, the exercise scaffolds
and their doctests, the coaching-instruction files — ran things, and reported
back; the human set the direction, reviewed every word and file that landed, and
cut. The check on the code is that it was run: every transcript in a reading,
every program in an examples/ folder, and every doctest here has been executed
before it was committed, and many of the commit bodies record the commands and
the counts. You can re-run all of it from a fresh clone with no install step. That
is an account of how the work was done, not a warranty — a defect that survived
a run is still a defect, and the log is public so you can find where one came
from.
Naming these modifications is part of satisfying
CC BY-NC-SA 4.0, which
requires an adapter to "indicate if You modified the Licensed Material." The
per-chapter ## Attribution sections indicate what changed in Downey's text;
this section indicates how the edition was made. Neither implies any endorsement
by Allen B. Downey or Green Tea Press — see LICENSE.md.
All 20 chapters are complete: readings, example programs, exercise scaffolds, coaching instructions, and licensing. The readings follow upstream's content and chapter numbering (repo chapter N = book chapter N−1).
Everything runs from a fresh clone with no install step — python3 and the files in this repository are the whole toolchain. Run example programs from their chapter folder (cd chapter08 && python3 examples/letter_counter.py); the turtle drawings need a graphical display, and the prompt-driven ones read from the terminal, so they stop with EOFError if you close their input. Doctests are how this book checks its own work and yours:
cd chapter08 && python3 -m doctest examples/letter_counter.py -v # passes: this code works
cd chapter08 && python3 -m doctest exercises/ex01_uses_none.py # fails: that code is yours to writeCHANGELOG.md records what this edition changes in Downey's original; LICENSE.md records what is covered by which license.
Every example-bearing chapter is themed (the list is in CHANGELOG.md); each chapter's theme is chosen so the capability that chapter adds is what the program is doing — regular expressions drive the newspaper copy desk in ch09, dictionaries fill the lexicographer's drawers in ch11, tuples get unpacked all over the puzzle night in ch12, shelve keeps the archive's index alive between runs in ch14, and mutation is the plot of the night depot in ch15.
This book covers the material typically found in an undergraduate CS1 course, including:
- Programming fundamentals and problem-solving
- Control structures (conditionals, loops)
- Functions and modular programming
- Data structures (lists, dictionaries, tuples)
- Object-oriented programming basics
- File handling and data processing
- Debugging and testing strategies
This book is designed for self-driven learning without the need for an instructor. You are the primary driver of your learning journey:
- Work through chapters at your own pace
- Pause and reflect on concepts as needed
- Revisit challenging topics without feeling rushed
- Customize your learning path based on your interests
Each chapter has tailored Copilot instructions (in .github/instructions/) that guide the AI assistant to coach you through exercises using a Socratic approach:
- Prediction — try to predict what code should do before running it
- Experiment — run your code and observe the actual result
- Observation — compare your prediction with what happened
- Explanation — ask Copilot for a hint, not the full solution
Each chapter's folder holds its reading, an examples/ folder of worked programs, and an
exercises/ folder of scaffolds. Work through them in order. The chapter number links to
its reading and the exercise count to its exercises/ folder; repo chapter N = book chapter
N−1.
Chapter 2's exercises are REPL drills inside the reading, and Chapter 20 has none, so neither
has an exercises/ folder.
