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 | |
|---|---|---|
| 1scores = [0] * 5 | AThe pseudocode bounds 1 to 5 were copied directly, so scores[i] skips the first element and scores[5] is out of range on the last pass. | |
| 2scores[i - 1] | BA list of 5 elements has indices 0 to 4, so scores[5] is out of range and causes an IndexError. The last element is scores[4]. | |
| 3Pseudocode index 1 is the first element, but the first element of a Python list is at index 0 | CCreates a Python list of 5 elements, all set to 0, to replace the pseudocode array Scores[1:5] | |
| 4A FOR loop from 1 to 5 over a pseudocode array becomes a Python loop over the indices 0 to 4 | DPython's way of writing the pseudocode element Scores[i] when the array starts at index 1 | |
| 5scores = [0] * 5 scores[5] = 90 | Escores[0] | |
| 6for i in range(1, 6): total = total + scores[i] | Ffor i in range(5): |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
scores[i - 1] — A pseudocode array starting at index 1 becomes a Python list starting at 0, so element Scores[i] is written scores[i - 1] in Python.# ARRAY[1:10] OF INTEGER
scores = [0] * 10# Scores[1] in pseudocode
print(scores[0])for i in range(1, 6):
print(scores[i - 1])# FOR i = 1 TO 5
for i in range(1, 6):
print(scores[i - 1])for i in range(1, 4):
total = total + scores[i - 1]