Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Stepping through code and watching variables worksheet is part of the VCE Applied Computing U1O2 Programming: Testing and debugging journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1step over | AThe variable watch panel shows that total currently holds the value 15 at this paused line | |
| 2watch: total = 15 | BThe faulty line is the first line where the watch value differs from the trace table, not the last line. Find the earliest mismatch. | |
| 3After pausing at a breakpoint, step over one line and check the watch panel to see if the value changed as expected | Ctotal = total + price | |
| 4Compare the watch panel value with the trace table row for the same step to find the first line that differs | DOnly 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. | |
| 5Run the whole program, then check the watch panel once at the end | ETrace: count = 3, Watch: count = 4 | |
| 6Watch shows total = 12, trace table says 10, so the error is in the last line of the program | FRuns the next line only, then pauses again so you can check the variables |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
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.total = 0
breakpoint()
total = total + 5total = 0
total = total + 5
print(total)total = 0
for i in range(1, 4):
total += itotal = 45
average = total / 3
print(average)if score >= 50:
print("Pass")