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 =", total) | Atotal = total + price print("total =", total) | |
| 2print("i =", i, "score =", score) | B# print("total =", total) | |
| 3Show the value of a variable after a calculation to check it is correct | CThe debug print is not indented, so it runs only once after the loop and does not show score changing each time. Fix: indent it inside the loop. | |
| 4Once the bug is fixed, remove the debug print or turn it into a comment so the output stays clean | DA debug print inside a loop that shows how i and score change on each pass | |
| 5print("total = total") | EA debug print that shows the current value of the variable total while the program runs | |
| 6for i in range(5): score = score + i print("score =", score) | FThe variable is inside the quotes, so it prints the words 'total = total' instead of the value. Fix: print("total =", total) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
print("total =", total) — A debug print. Add a line like this to show a variable's value while the program runs, so you can spot where it goes wrong. Put one inside a loop to watch it change, then remove it once fixed.total = 0
total = total + 5
print("total =", total)for i in range(3):
total = total + i
print("total =", total)for num in scores:
total = total + num
print("num =", num)total = total + price
# print("total =", total)
print(total)while count < 3:
print("count =", count)
count = count + 1