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,4,5] nums[1,3] | AError: Slice step cannot be zero | |
| 2nums = [1,2,3] nums[::0] | BOutput: [1, 3, 5] | |
| 3nums = [1,2,3,4,5] nums[1:4] | COk: Reverses the list | |
| 4nums[::-1] | DOutput: [10, 20, 30] | |
| 5n = [10,20,30,40,50] print(n[:3]) | EValid: Returns [2, 3, 4] | |
| 6n = [1,2,3,4,5] print(n[::2]) | FError: Use colon for slicing |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
list[start:stop] — Get items from start up to but not including stop.~~list[:stop]nums = [10, 20, 30, 40]
print(nums[0:3])nums = [10, 20, 30, 40]
print(nums[2:4])nums = [1, 2, 3, 4, 5]
print(nums[::-1])nums = [1, 2, 3]
copy = nums[:]nums = [10, 20, 30, 40, 50]
print(nums[:2])