Computing · Stage 4

Challenge: Trace the Program

Thinking It Through · programming · follow a program step by step to predict its output

✦ Computing📘 Stage 4 · S4⏱ ~10 min🧒 Ages 8–9★ Free to start
I can follow a program to predict its output.
Kavi the owl for Computing
📖

Kavi Becomes the Computer

Kavi stared at a little program and asked, "What will it print?" Instead of guessing, Kavi decided to be the computer. Kavi started at the first value, then read one line at a time, doing exactly what each line said and keeping track of the number. set score = 2 · add 3 · take 1. "Two… plus three is five… take one is four," Kavi whispered. When the last line said print score, Kavi knew the answer before the computer did — 4! "Following a program step by step is called tracing," Kavi hooted, "and it never lies."

🎓

What your child will learn

1Be the computerTo trace a program means to follow it one line at a time, just like the computer does, and keep track of the value. Do the lines in order and never skip — then you can tell what it will print. Tap each part to hear its job.
2Trace a program line by linePress ▶ Run and follow along. Start at the first value, then do each line in order and watch the number change — the last line prints the output.
3Guess the answer, or trace it?You could guess what a program prints — but a guess is often wrong. Tracing means you do exactly what each line says, in order, so your answer matches what the computer really does.
🔍

A peek inside

Trace it: set score = 0 · add 4 · add 2 · print score. What does it print?
start at 0, add 4 → 4, add 2 → 6

Try this at home: Following a program one line at a time to see what it does is called ____.

Ready to play and learn?

Start the free interactive lesson, or print the handout for screen-free play.

Part of Computing · Stage 4 · S4 on KAVI Academy — a secular, whole-child learning platform for ages 5–12.