What is a tuple in Python?
A collection of items that is ordered and unchangeable (immutable).
What is a dictionary in Python?
A collection of key-value pairs.
What is a list in Python?
A list is an ordered collection of items that can be changed (mutable).
A collection that is ordered and can change
List
How do you create a tuple with one item?
Add a comma, like (item,)
How do you access a value in a dictionary?
Use its key, like dictionary[key].
How do you create a list with three numbers: 1, 2, and 3?
my_list = [1, 2, 3]
A collection that is ordered but cannot change?
Tuple
Can you change a value in a tuple? Why or why not?
No, because tuples are immutable
What is the result of this code?
12
What method do you use to add an item to the end of a list?
append()
A collection where each item has a unique key?
Dictionary
What is the result of this operation: len((1, 2, 3, 4))?
4
How do you add a new key-value pair to a dictionary?
dictionary[new_key] = value.
How can you remove an item from a list by its value
remove()
What method would you use to add an item to a list at a specific index?
insert()
What happens if you try to use .append() on a tuple?
It will throw an error because tuples do not support item addition.
Can a dictionary have duplicate keys?
No, keys in a dictionary must be unique
What does the following code print:
[20, 30]
How do you create a copy of a list?
list.copy() or list[:]