S3U

Science / Programming basics / Grade 3 / sc370

Programming Basics: Track a Variable

Keep a record of a value as instructions change it.

All worksheets
5 questions0m 0s
Learn the skill

These sheets use pseudocode: readable instructions, not a particular programming language. SET score TO 2 gives score the value 2. SET score TO score + 3 reads the old value first, then replaces it. SHOW displays the current value without changing it.

Worked example

Trace SET score TO 2; SET score TO score + 3; SHOW score. The values are 2 then 5, and the display shows 5. A variable is a name for a value, not the printed word itself.

SET score TO 2 stores two. SET score TO score + 3 reads two and stores five. SHOW score displays five without changing the stored value.
SET score TO 2 stores two. SET score TO score + 3 reads two and stores five. SHOW score displays five without changing the stored value.
Question 1 What is score after SET score TO 2?
Question 2 What is score after the next instruction adds 3?
Question 3 What does SHOW score display at the end?
Question 4 If the next instruction is SET score TO 1, what is score now?
Question 5 Does SHOW score change score in this pseudocode?