Challenge: Trace & Predict Code
Programs & Judgement · challenge · hand-trace code line by line to predict its output

Kavi Reads the Code Before Pressing Run
Kavi's friend wrote a little program and asked, "What will it print?" Kavi did not press ▶ Run. Instead Kavi hand-traced it — reading each line in order and keeping a little trace table of the values. score = 1 … then +5 → 6 … then a loop that doubled it twice → 12, then 24. "It will print 24," Kavi said. When the program finally ran, the screen showed 24! "A good coder can predict the output of their own code," Kavi hooted, "by tracing it line by line — before the computer ever runs it."
What your child will learn
A peek inside
Try this at home: Reading a program line by line, keeping track of the values, to work out its result is called ____.
Ready to play and learn?
Start the free interactive lesson, or print the handout for screen-free play.
Part of Computing · Stage 6 · S6 on KAVI Academy — a secular, whole-child learning platform for ages 5–12.
