11Knowledge Check: Modifying Lists

Test your understanding of Module 11. Answer the 10 questions below.
You need 6 correct answers to pass. You can attempt this check as many times as you like. Passing will update your course progress.

1. Which method adds an element to the very end of a list?

2. What is the result of the following code?
my_list = [10, 20, 30]
my_list.insert(1, 15)
print(my_list)

3. Which statement is used to remove an item from a list using its index, without returning the removed item?

4. Consider the list items = ['a', 'b', 'c', 'd']. What does items.pop(1) return?

5. If you want to remove the first occurrence of the value 'apple' from a list called fruits, which method should you use?

6. What happens if you try to use .remove(value) on a list where value does not exist?

7. Given letters = ['x', 'y', 'z'], what does letters.pop() (without an index) do?

8. How can you replace the items at index 1 and 2 in my_list = [0, 1, 2, 3] with the single value 99?

9. What is the value of numbers after this code executes?
numbers = [1, 2, 3, 4, 5]
del numbers[1:3]

10. Which of the following methods modifies the original list in-place (directly changes the list object)?