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] * 10 | AThe * is inside the brackets, so it makes a list with one element (0 * 10 = 0), not 10 elements. It should be [0] * 10. | |
| 2names = [''] * 5 | BSIZE = 10 scores = [0] * SIZE | |
| 3Use a constant for the size so the array length can be changed in one place | Cscores[2] = 85 | |
| 4Fill an element of a set-size array by its index | DUses + instead of *. A list cannot be added to a number, so this causes an error. It should be [0] * 10 to repeat the 0 ten times. | |
| 5scores = [0] + 10 | ECreates an array of 5 empty strings ready to be filled | |
| 6scores = [0 * 10] | FCreates an array of 10 elements, all starting at 0 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
scores = [0] * 10 — Creates a one-dimensional array (list) of 10 elements that all start with the value 0. Change the number to set the size, or use '' for strings.scores = [0] * 10# Array for 5 student names
names = [''] * 5SIZE = 8
marks = [0] * SIZESIZE = 5
scores = [0] * SIZE
scores[0] = 75scores = [0] * 10
for i in range(len(scores)):
scores[i] = i * 5