← VCE Applied Computing U1O2

Stepping through code and watching variables

Run the next line only, then pause again. Check the variable watch panel after each step to see which line first gives a wrong value.

Understanding Stepping through code and watching variables in VCE Applied Computing U1O2

What it does: Each time this line is stepped over, the watch panel should show total increase by price. If it does not, this line is the fault. The faulty line is the first one where a variable gets a value that is not what you expected.

Common mistakes: count should start at 0. When you step over this line, the watch panel shows count as 1 before any marks are processed. It ends at 4 and the average is wrong. The line should be count = 0. Stepping through shows lives going up (4, 5, 6...) instead of down, so the loop never ends. The line should be lives = lives - 1.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 89–124) and word search (Modules 8–124).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A breakpoint has paused your program. What does 'step over' do?
Runs the next line only, then pauses againRuns the rest of the program without stopping
Matches
Run the whole program, then check the watch panel once at the end
↓
Only checking variables at the end hides which line caused the error. Step over one line at a time and check the watch panel after each step.
Applying
Meanings
Term
step over
Meaning
Run the next line only, then pause again. Check the variable watch panel after each step to see which line first gives a wrong value.
Practice
total = 0
Testing
Gaps
()
Check Answer
Spots
1total = 0
2count = 1

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Silverback Gorilla' badge — Savannah Master, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A breakpoint has paused your program. What does 'step over' do?
A. Runs the next line only, then pauses again ✓
B. Runs the rest of the program without stopping
Step over moves forward one line at a time so you can check what changed after each line.
2. After each step, where do you look to see how variable values have changed?
A. The file name at the top of the editor
B. The variable watch panel ✓
The variable watch panel lists each variable and its current value, so you can spot when one becomes wrong.
3. What are you trying to find while you step through the code?
A. The first line that gives a wrong variable value ✓
B. The last line in the program
The faulty line is the first one where a variable gets a value that is not what you expected.
4. Before running line total = total + price, total is 10 and price is 5. The watch panel then shows total as 5. What does this tell you?
A. That line is faulty, because total should now be 15 ✓
B. That line is fine, because the value changed
A changed value is not enough. It must match what you expected. Here the line probably used = price instead of adding.
5. Which approach finds a logic error more precisely?
A. Run the whole program and guess which line is wrong
B. Step through one line at a time and check the watch panel ✓
Stepping shows exactly where a value first goes wrong, rather than only showing the final wrong output.

Match the Pairs

step over → Runs the next line only, then pauses again so you can check the variables
watch: total = 15 → The variable watch panel shows that total currently holds the value 15 at this paused line
After pausing at a breakpoint, step over one line and check the watch panel to see if the value changed as expected → total = total + price
Compare the watch panel value with the trace table row for the same step to find the first line that differs → Trace: count = 3, Watch: count = 4
Run the whole program, then check the watch panel once at the end → Only checking variables at the end hides which line caused the error. Step over one line at a time and check the watch panel after each step.
Watch shows total = 12, trace table says 10, so the error is in the last line of the program → The faulty line is the first line where the watch value differs from the trace table, not the last line. Find the earliest mismatch.

Key Term

step over
Run the next line only, then pause again. Check the variable watch panel after each step to see which line first gives a wrong value.

Fill in the Blanks

1. total = 0 breakpoint() total = total + 5
Hint: Type the built-in Python function that pauses the program so you can start stepping.
2. total = 0 total = total + 5 print(total)
Hint: Type the operator that adds to the running total. After you step over this line, the watch panel should show 5.
3. total = 0 for i in range(1, 4): total += i
Hint: Type the function that makes the sequence of numbers the loop steps through.
4. total = 45 average = total / 3 print(average)
Hint: Type the operator that divides. Step over this line and check the watched value of average.
5. if score >= 50: print("Pass")
Hint: Type the comparison operator for greater than or equal to. Step over the if line to see which branch runs.

Spot the Error

Question 1
A total = 0
B count = 1
C for mark in [70, 85, 90]:
D total = total + mark
E count = count + 1
F print(total / count)
Line B — count should start at 0. When you step over this line, the watch panel shows count as 1 before any marks are processed. It ends at 4 and the average is wrong. The line should be count = 0.
Question 2
A lives = 3
B score = 0
C while lives > 0:
D lives = lives + 1
E score = score + 10
F print(score)
Line D — Stepping through shows lives going up (4, 5, 6...) instead of down, so the loop never ends. The line should be lives = lives - 1.
Question 3
A price = '20.00'
B discount = 0.25
C sale = price - price * discount
D print(sale)
Line A — The quotes make price a string, and the watch panel shows it as text. Line 3 then fails because you cannot multiply a string by a number. It should be price = 20.00.
Question 4
A a = 5
B b = 9
C temp = a
D b = a
E b = temp
F print(a, b)
Line D — The swap breaks here. Stepping over this line shows a and b both holding 5, and the old value of b is lost. It should be a = b so that b = temp can then finish the swap.
Question 5
A age = int(input('Age: '))
B fee = 10
C if age > 18:
D fee = 5
E print(fee)
Line C — The condition is reversed. When you step over it with age 25, the program runs the discount line and the watch panel shows fee as 5 for an adult. It should be if age < 18:.

Student with a class code? Join your class →