Recall & Review
beginner
What does it mean that lists in Python are mutable?
It means you can change, add, or remove items in a list after it is created without making a new list.
Click to reveal answer
beginner
Which of these operations changes a list in place?
my_list = [1, 2, 3]
Operations like
my_list.append(4) or my_list[0] = 10 change the list without creating a new one.Click to reveal answer
intermediate
What happens if you assign a new list to a variable that held a list before?
The variable now points to a new list. The old list stays unchanged unless other variables also point to it.
Click to reveal answer
beginner
True or False: Strings in Python are mutable like lists.
False. Strings are immutable, meaning you cannot change them after creation, unlike lists.
Click to reveal answer
intermediate
How does list mutability affect function arguments when you pass a list?
If you change the list inside the function, the change affects the original list outside the function because both refer to the same list.
Click to reveal answer
Which method changes a list by adding an item at the end?
✗ Incorrect
The append() method adds an item to the end of a list. The others are not valid list methods.
What will this code print?
lst = [1, 2, 3] lst[1] = 5 print(lst)
✗ Incorrect
Changing lst[1] to 5 updates the second item. Lists are mutable, so the change is allowed.
If you do
new_list = old_list and then change new_list, what happens to old_list?✗ Incorrect
Both variables point to the same list, so changes via new_list affect old_list.
Which of these types is immutable in Python?
✗ Incorrect
Strings cannot be changed after creation, unlike lists, dictionaries, and sets.
What does mutability allow you to do with a list?
✗ Incorrect
Mutability means you can change the list's contents directly.
Explain what list mutability means and give an example of changing a list item.
Think about how you can change a list after you create it.
You got /3 concepts.
Describe how passing a list to a function can lead to changes outside the function.
Consider what happens if you add or remove items inside the function.
You got /3 concepts.