Answer key · 12 questions

Python Lists Exercises With Answers

All 12 questions for Python Lists in one place. Try the practice page first, then use this page to check the exact answer and the reason.

Quick answer

This answer key contains 4 multiple-choice, 4 fill-in-the-blank, and 4 output-prediction questions for Python Lists, with the exact answer and a short explanation for every question.

The answers are shown in full, so use this page after making an attempt. The practice page is the better first pass.

01 · Multiple choice

What is the index of the first item in a list?

  1. -1
  2. The length of the list
  3. 1
  4. 0correct

Answer: 0

Why: Python list indexes start at 0.

02 · Multiple choice

What does orders.append("tea") do?

  1. Returns a new list
  2. Adds tea to the start of the list
  3. Adds tea to the end of the listcorrect
  4. Removes tea from the list

Answer: Adds tea to the end of the list

Why: append changes the list in place and adds one item at the end.

03 · Multiple choice

How many items are in [10, 20, 30, 40][1:3]?

  1. 3
  2. 4
  3. 2correct
  4. 1

Answer: 2

Why: The slice starts at index 1 and stops before index 3, so it contains 20 and 30.

04 · Multiple choice

What is len([1, 2, 3])?

  1. 6
  2. 4
  3. 3correct
  4. 2

Answer: 3

Why: len counts the number of items in the list.

05 · Fill in the blank

Complete the method that adds 4 to the end of the list.

items = [1, 2, 3]
items.____(4)

Answer: append

Why: append adds one item to the end of a list.

06 · Fill in the blank

Complete the index that reads the first item.

numbers = [10, 20, 30]
print(numbers[____])

Answer: 0

Why: The first position in a Python list is index 0.

07 · Fill in the blank

Complete the method that puts the numbers in ascending order.

numbers = [3, 1, 2]
numbers.____()

Answer: sort

Why: sort() changes the list in place.

08 · Fill in the blank

Complete the function that adds the numbers in the list.

print(____([4, 5, 6]))

Answer: sum

Why: sum(list) returns the total of numeric values.

09 · Predict output

What does the program output?

print([10, 20, 30][1])

Answer: 20

Why: Index 1 is the second item.

10 · Predict output

What appears on the screen?

items = [1, 2]
items.append(3)
print(items)

Answer: [1, 2, 3]

Why: append adds 3 to the end of the list.

11 · Predict output

What is printed?

print([1, 2, 3, 4][1:3])

Answer: [2, 3]

Why: The slice includes indexes 1 and 2, but not 3.

12 · Predict output

What is the output?

print(sum([4, 5, 6]))

Answer: 15

Why: The sum of 4, 5, and 6 is 15.

Try the questions first

Open the practice page for Python Lists and answer the same 12 questions with instant feedback.

Practice this lesson