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 = [] | Aappend() changes the list itself and gives back None, so assigning the result wipes out the list. It should be just scores.append(10). | |
| 2pets.append("cat") | Bfor i in range(5): nums.append(i) | |
| 3Use append() inside a loop to build a list of the numbers 0 to 4 | Cappend is a method so it needs round brackets (), not square brackets []. It should be fruit.append("apple"). | |
| 4Ask the user for a name and add it to the end of the names list | DAdds the value "cat" to the end of the pets list, making it one item longer | |
| 5fruit = [] fruit.append["apple"] | EStarts with an empty list that has no items yet, ready to be filled with append() | |
| 6scores = [] scores = scores.append(10) | Fnames.append(input("Name: ")) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
list.append(value) — Adds a value to the end of a list, making it one item longer. Start with an empty list like scores = [] and use append() in a loop to build it up.scores = []
scores.append(9)scores = []
scores.append(10)scores = []
for i in range(5):
scores.append(i)scores = []
for i in range(5):
scores.append(i * 2)scores = []
score = int(input("Score: "))
scores.append(score)