Home›Lesson Plans›Computer Science›Programming · Grade 9

Tracing Code

Ninth graders learn to trace code by hand — following it line by line, tracking each variable in a table, and predicting the output before running it. Tracing is how you truly understand what a program does (and find bugs). They order the steps, then trace a program.

Grade 9Tracing Code by Hand55 minutes1 class periodCSTA / ISTEExplicit teaching4 StandardsCSTA
Start the Lesson
Assign or share this lesson

Copy link works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment.

Lesson at a Glance

Everything you need before the bell rings

Learning Objectives

Students will be able to…

  • ✓Trace code by hand.
  • ✓Track variables.
  • ✓Follow control flow.
  • ✓Predict the output.
Essential Question

How can you figure out what code does without running it?

0
Lesson Phases
0
Vocabulary Terms
0
Standards Aligned
0
Interactive Task
Put in Order · Interactive

Order the Tracing Steps

Project this and have students put the code-tracing steps in order.

🔍 Put the code-tracing steps in orderTry it
Tap the first step to trace a program!
The Lesson · Explicit teaching

55 minutes, five moves

Tap any phase to open the teacher moves and student actions.

1

Hook — In Your Head

6 min

Can you predict a program’s output before you run it?

👩‍🏫 Teacher Moves

  • Show a short program.
  • Ask the question.
  • Set the goal.

🎒 Student Actions

  • Think.
  • Share.
  • Get ready.
2

Use — Tracing

13 min

Students learn.

👩‍🏫 Teacher Moves

  • Send students to Order the Tracing Steps.
  • Order the steps.
  • Note track variables in a table.

🎒 Student Actions

  • Order.
  • Say.
  • Note it.
3

Modify — Trace It

14 min

Students practice.

👩‍🏫 Teacher Moves

  • Trace a short program.
  • Fill a variable table.
  • Predict the output.

🎒 Student Actions

  • Trace.
  • Table.
  • Predict.
4

Create — Create

15 min

Students apply.

👩‍🏫 Teacher Moves

  • Trace a program with a loop.
  • Predict its result.
  • Run it to check.

🎒 Student Actions

  • Trace.
  • Predict.
  • Check.
5

Reflect — Reflect

7 min

Students close.

👩‍🏫 Teacher Moves

  • What do you track while tracing?
  • Why trace before running?
  • Complete the exit ticket.

🎒 Student Actions

  • Say it.
  • Say it.
  • Complete the exit ticket.
Standards Alignment

Built to the standards you report on

Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students.

CSTA
3A-AP-21

Evaluate and trace program execution.

CSTA
3A-AP-17

Systematically test and debug.

CSTA
3A-AP-23

Document and reason about code.

ISTE
5c

Reason about program behavior.

Differentiation

One lesson, every learner

Multilingual Learners

ELL / EMERGING READERS
  • Tracing-step cards.
  • Frame: "I track each ___ in a table."
  • Trace together slowly.

Support & Access

IEP / 504
  • Use 3 core steps.
  • Trace a 3-line program.
  • Use a variable table template.

Stretch & Extend

GIFTED / EARLY FINISHERS
  • Trace nested control flow.
  • Find a bug by tracing.
  • Trace recursion simply.
Materials

What to gather

  • 📽️Screen / board
  • 🔍Trace-step cards
  • 💻Order the Tracing Steps
  • 📋Variable-table worksheet
  • 📓Notebooks
  • 🎫Exit-ticket slips
Vocabulary

Key terms — hover for a quick definition

tracefollow code by handvariablea named stored valuevariable tablea chart of variable valuescontrol flowthe order code runsoutputwhat a program displayspredictsay what will happenstep throughgo line by linedebugfind and fix errors
Evaluate

Exit Ticket

Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students.

QUESTION 1
What do you track while tracing code?
Each variable’s value in a table.
QUESTION 2
What do you follow through loops and if/else?
The control flow.
QUESTION 3
Why trace before running?
To truly understand the code and catch bugs.

Reflect: tracing code.

Have students trace a program and predict its output. A printable variable-table worksheet is in the CS library.

Study · Flashcards

Study the key terms

Tap a card to flip it, then rate whether you knew it. Built from this lesson’s vocabulary.

🃏 Tracing CodeFlip
Card 1
Term
Tap to flip →
Meaning
0

Nice work!

Practice · Quiz

Check your understanding

A quick self-check with instant feedback, drawn from this lesson’s key terms.

📝 Tracing CodeQuiz
Score: 0
1 / 6
Question 1
0%

Nice work!

Practice · Worksheet

Printable worksheet

A print-and-go review sheet with a built-in answer key. Tap “Show answer key” to reveal answers, or print the clean version for students.

🖨️ Tracing CodePrint
Name: ________________________
Date: ____________

Part A · Write the word that matches each meaning

Word bank: control flow, debug, output, predict, step through, trace, variable, variable table
  1. a named stored value
  2. what a program displays
  3. say what will happen
  4. follow code by hand
  5. a chart of variable values
  6. go line by line
  7. the order code runs
  8. find and fix errors

Part B · Show what you learned

  1. What do you track while tracing code?
  2. What do you follow through loops and if/else?
  3. Why trace before running?
Answer key — Part A: 1) variable · 2) output · 3) predict · 4) trace · 5) variable table · 6) step through · 7) control flow · 8) debug
Part B: 1) Each variable’s value in a table. 2) The control flow. 3) To truly understand the code and catch bugs.