About this book

Read code like a computer. Write code that works.

High-school learners trace short Python programs line by line, then write and test their own with variables, conditions, loops, lists and functions. Debugging pages teach how to read errors and document a reproducible fix.

  • Trace state changes with trace tables
  • Write small programs with explicit tests
  • Read error messages and fix bugs step by step

Tracing and runnable tasks, with explained answers

What this book covers

Covered

  • Values, types, variables, and print
  • Comparisons and if / elif / else
  • for and while loops, lists, and indexes
  • Functions, return values, and assert tests
  • Trace tables and a repeatable way to fix bugs

Not covered

  • Files, classes, and installed libraries
  • Graphics, games, and web programs

Before you start, you should be able to

  • Follow a list of steps in order
  • Use +, -, × and ÷ with whole numbers
  • Decide whether a comparison such as 4 < 7 is true
  • Read short English-like instructions

Things to have

  • A pencil and this book: every task can be done on paper
  • For Run tasks: a computer with Python 3.10 or newer and a plain editor such as IDLE
  • Written for Python 3.10 or newer; examples checked with Python 3.11, 3.12 and 3.13 in October 2026

Notice

Pictures in this book are simplified learning models. Check answers with the explanations at the back of the book.

The steps in this book

  1. Step 1: Readiness Check

    Check the skills you need before you begin. If something feels tricky, an adult can help you start in the right place.

  2. Step 2: Concept

    Read a short, clear explanation of the new idea and the words that go with it.

  3. Step 3: Worked Example

    Watch the idea being used, one step at a time, in a worked example.

  4. Step 4: Guided Practice

    Practice with prompts and help cues. The help gets smaller as you get stronger.

  5. Step 5: Independent Practice

    Practice on your own with different kinds of questions, and explain your thinking.

  6. Step 6: Review

    Look back at earlier learning so it stays strong, then check where to go next.

  7. Step 7: Answers and Explanations

    Check your answers. Each answer explains why, names a common mistake, and shows how to fix it.

What is in the book

The modules

  1. Module 1: Values, variables, and outputPages 5–14
  2. Module 2: Conditions choose a pathPages 15–24
  3. Module 3: Loops and lists process collectionsPages 25–34
  4. Module 4: Functions, tests, and debuggingPages 35–44

Contents

  1. Readiness check, pp. 3–4. Before Module 1. Its table tells you where to start.
  2. Modules, pp. 5–44
  3. Checkpoints, pp. 14, 24, 34, 44. The last page of each module.
  4. Mixed review, pp. 45–48. Questions from across the book, mixed together.
  5. Exit check, pp. 49–50. A last check across the book.
  6. Reflect and repair, p. 51
  7. Try again, p. 52. Fresh questions like those in the exit check.
  8. Extra practice, pp. 53–55
  9. Answers and explanations, pp. 56–64. Notes in this part are headed “Why”, “Common mistake”, “Help” and “Look for”.