Lists – Methods (append, remove, pop, insert)

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Lists – Methods (append, remove, pop, insert)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does append() do?
A Adds an item to the end
B Adds to the start
2. What does pop() do?
A Removes and returns the last item
B Adds an item
3. What does remove('cat') do?
A Removes the first 'cat'
B Removes all 'cat'
4. nums = [1,2,3]\nnums.insert(1, 99)\nWhat is nums?
A [99, 1, 2, 3]
B [1, 99, 2, 3]
5. nums = [3,1,2]\nnums.sort()\nWhat is nums?
A [3, 2, 1]
B [1, 2, 3]

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight 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

Definitions

.append(item)

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
nums = [1, 2, 3] nums.______(4) print(nums)
2.
nums = [1, 2, 3] nums.______(0, 99) print(nums)
3.
pets = ['cat', 'dog'] pets.______('cat') print(pets)
4.
nums = [10, 20, 30] last = nums.___() print(last)
5.
nums = [3, 1, 2] nums.____() print(nums)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A nums = [1, 2, 3]
B nums = nums.append(4)
C print('List:', nums)
D print('Done')
Question 2
A nums = [1, 2, 3]
B nums.append(4, 5)
C print('List:', nums)
D print('Done')
Question 3
A nums = [1, 2, 3]
B nums.remove(5)
C print('List:', nums)
D print('Done')
Question 4
A nums = [1, 2, 3]
B nums.append[4]
C print('List:', nums)
D print('Done')
Question 5
A sorted_nums = [3, 1, 2].sort()
B nums = [3, 1, 2]
C print('Sorted:', sorted_nums)
D print('Done')

Answer Key

Lists – Methods (append, remove, pop, insert)
Section A: Quick Questions
Q1
A — Adds an item to the end
Q2
A — Removes and returns the last item
Q3
A — Removes the first 'cat'
Q4
B — [1, 99, 2, 3]
Q5
B — [1, 2, 3]
Section B: Match the Pairs
Q1
nums = [1,2,3] nums.remove(99) → Error: 99 not in list
Q2
nums = [] nums.pop() → Error: pop from empty list
Q3
nums.append(4) → Valid: Adds 4 to end of list
Q4
nums.insert(0, 'new') → Ok: Inserts 'new' at index 0
Q5
n = [1,2,3] n.append(4) print(n) → Output: [1, 2, 3, 4]
Q6
n = [1,2,3] print(n.pop()) → Output: 3
Section C: Definitions
Q1
.append(item) — Adds an item to the end of the list.~~.insert(index, item)
Section D: Fill in the Blanks
Q1
nums = [1, 2, 3] nums.append(4) print(nums)
Q2
nums = [1, 2, 3] nums.insert(0, 99) print(nums)
Q3
pets = ['cat', 'dog'] pets.remove('cat') print(pets)
Q4
nums = [10, 20, 30] last = nums.pop() print(last)
Q5
nums = [3, 1, 2] nums.sort() print(nums)
Section E: Spot the Error
Q1
B — append() returns None: don't assign it back. It modifies the list in-place.
Q2
B — append() takes exactly one argument: add items one at a time
Q3
B — 5 is not in the list: remove() raises ValueError
Q4
B — Use parentheses () to call methods, not square brackets []
Q5
A — sort() returns None: it modifies in-place. Use sorted() to get a new sorted list.