Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
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 | |
|---|---|---|
| 1print(total) # trace said 15, output 12 | AThe program was run with a different input (5) than the one traced (3), so the output cannot be compared with the trace | |
| 2n = int(input()) # trace used n = 4, run with 4 | BThe real output differs from the trace, so either the trace or the code has a mistake and needs re-tracing | |
| 3If the trace shows 10 but the program prints 10, the trace and the code agree, so no mistake is found for that input | CRun the program with the same input you used in the trace so the two can be compared fairly | |
| 4If the output differs from the trace, re-trace the code line by line to see where the trace and the program split apart | DAssuming the code is wrong without checking the trace; a mismatch could be a tracing slip, so re-trace before changing the code | |
| 5# traced with n = 3 n = 5 print(n * 2) # compare with trace | E# trace: total = 10 print(total) # output: 10 | |
| 6# trace: 8, output: 6 # so the code must be wrong print(result) | F# trace: x = 6, output: x = 5 # re-trace from the first line |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace vs output — Run the code with the same input you traced, then compare. If the real output differs from your trace, either the trace or the code has a mistake, so re-trace.expected = 12
actual = sum([2, 4, 6])
print(expected == actual)traced = 12
output = 10
if traced != output:n = 5
print(n * 2)
print(n + 1)msg = "OK" if trace == output else "Retrace"def double(n):
return n * 2
print(double(4))