Skip to content
All course tools
Code tracing

See if students can follow the code.

Students predict what a program prints and what its variables end up as, before they run anything.

What does it do?

Show students a program and ask what it prints and where its variables end up. It’s a quick way to see whether they can follow code before you ask them to write it.

Try it as a student
Loading the lesson block…

Who is it for?

Introductory CS teachers

Check that students can read code before they write their own.

Students

Practice following loops and variables step by step.

How do I use it?

  1. Add a Code Tracing activity to your lesson.
  2. Paste the program and enter its output and variable values.
  3. Set points and formatting rules, then preview it.
Follow the setup guide

Features

Output and variables

Paste in a program, then ask for its output and the final value of any variables you name.

Answer matching

Ignore case and spacing, so students aren’t marked wrong for formatting.

Related practice

Follow up with a Parsons problem, where students rebuild the program from shuffled lines.

Questions

Do students run the code?

No. They predict the result first. Follow up with a Code Exercise when you want them to run and edit it.

Works with other tools

Use these together in the same course.