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 | |
|---|---|---|
| 1nums = [1,2,3] nums.remove(99) | AValid: Adds 4 to end of list | |
| 2nums = [] nums.pop() | BOk: Inserts 'new' at index 0 | |
| 3nums.append(4) | CError: 99 not in list | |
| 4nums.insert(0, 'new') | DError: pop from empty list | |
| 5n = [1,2,3] n.append(4) print(n) | EOutput: [1, 2, 3, 4] | |
| 6n = [1,2,3] print(n.pop()) | FOutput: 3 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
.append(item) — Adds an item to the end of the list.~~.insert(index, item)nums = [1, 2, 3]
nums.append(4)
print(nums)nums = [1, 2, 3]
nums.insert(0, 99)
print(nums)pets = ['cat', 'dog']
pets.remove('cat')
print(pets)nums = [10, 20, 30]
last = nums.pop()
print(last)nums = [3, 1, 2]
nums.sort()
print(nums)