Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Phase 3 — Python basics

Phase 2 used the turtle to make typing Python feel friendly and visual. This phase is where Python becomes general-purpose — the language used by professionals to write everything from scripts that automate work, to data analysis, to web servers, to AI tools.

What this phase is

The biggest phase in the curriculum. Sixteen sessions on the core building blocks of Python: text, numbers, decisions, loops, functions, lists, dictionaries, files, and error handling. By the end, you’ll be able to write small programs that talk to people, store information, read and write files, and handle mistakes gracefully.

We leave the turtle behind. No more drawings on a stage. Instead, your programs run in the shell at the bottom of Thonny — they print things, ask the user questions, and respond based on what they’re told. Less visual, more flexible. Most software in the world works this way at its core.

What you’ll learn

SessionIdeaWhat’s new
1Welcome to Python without turtleprint, input, the shell
2Variables and typesint, float, string, type conversion
3Stringsconcatenation, methods, f-strings, indexing
4Conditionals (deeper)and, or, not; multi-condition logic
5Loops + the Thonny debuggerwhile loops; the debugger formally
6Functions + return valuesreturn; thinking about scope
7First real project — number-guessing gameFirst text-based game
8Liststhe most important data structure in Python
9More lists; iteration patternsfor over lists, len, append, slicing
10Dictionarieskey-value lookups
11Reading filesopen, line iteration
12Hangmanbigger project applying lots
13Error handlingtry / except
14Putting it together — text adventure or CSV readerBig integration project
15Milestone project work day 1Plan + build
16Milestone project work day 2 + demoPolish + demo

A lot of these sessions cover ideas you’ve already seen in Phase 1 (Scratch) or Phase 2 (Turtle) — variables, conditionals, loops, functions. What’s new is how Python does each one in a text-based context, plus several genuinely new tools: lists, dictionaries, files, the debugger, and proper error handling.

What you’ll build

Multiple working programs throughout the phase, not just one big project at the end:

  • Session 1: a tiny program that asks for your name and greets you.
  • Session 7: a number-guessing game. The computer thinks of a number; you have to guess it.
  • Session 12: a hangman game. Real game logic, real word list, real win/lose conditions.
  • Session 14: a text adventure or a CSV reader. Multi-room, multi-choice text-based game, OR a program that reads a real file (Bible verses, sports stats, whatever interests you) and does something with it.
  • Session 16: a milestone project of your own design. Free choice within “make something using Python that does something useful or fun.”

What you’ll need

Same machine as Phase 2 — Thonny is already installed; nothing new to install for Phase 3. The Python turtle library you used in Phase 2 is replaced with Python’s built-in print, input, file I/O, and other tools — all of which come standard with Python.

If you want to work at home, the Installing on your own computer appendix has Thonny instructions.

How sessions work

Same shape as Phases 1 and 2:

  • Part A introduces a new idea with a guided exercise. Stands alone if class gets cut short.
  • Part B is open practice or a project that uses Part A. Often tiered (base / stretch / extension).
  • Wrap-up — a few minutes of sharing what you did.

A note about the shell

Phase 2 had two windows: Thonny (where you typed code) and the turtle window (where drawings appeared). Phase 3 uses just Thonny. The shell at the bottom of the editor is where your program prints things and where you type answers when it asks.

The shell is also useful by itself — you can type one-line Python expressions there and press Enter to see what they do. We’ll use it for quick experiments throughout the phase.

A note about errors

Phase 2 had typos and syntax errors. Phase 3 will have more of them — partly because the syntax is more varied, partly because your programs are doing more. The Reading error messages appendix gets fleshed out as Phase 3 progresses.

The single best advice: read the error message slowly. Python’s errors are friendlier than they look once you get used to them.

Where to start

Session 1: Welcome to Python (without the turtle) opens with a callback to a moment from Session 1 of Phase 1. You might want to glance at the Phase 1 Welcome chapter before reading, just to remember.

When you’re stuck, the Getting unstuck appendix has the checklist. The Glossary explains vocabulary. New terms get added as Phase 3 introduces them.

Welcome to general Python. Let’s go.