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 | |
|---|---|---|
| 1# total = total + price | AA block of lines commented out one by one, so none of them run while the bug is being isolated. | |
| 2# print(average) # print(count) | BThis line is commented out, so Python skips it and does not add the price to the total. | |
| 3Restore disabled code after testing by removing the # from the front of the line. | Ctotal = total + price | |
| 4Comment out the suspect line to see if the bug disappears when that line does not run. | DThe # is placed after the code, so the line still runs. The # must go at the start of the line to disable it. | |
| 5total = total + price # print(total) | EOnly the for line is commented out, leaving an indented line that causes an IndentationError. Comment out the whole block. | |
| 6# for item in prices: total = total + item | F# result = 10 / count |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
# (commenting out) — Putting # in front of a line, or a selected block, stops Python running it. Use this to isolate a bug, then remove the # to restore the code.# print(total / count)# for n in nums:
# total += n
print(len(nums))total = 10
count = 2
print(total / count)name = "Sam"
# age = int("twelve")
print(name)if score > 50:
# print("Pass")
print("Done")