Quiz Complete, well Done!
The function used to check if a key is present in a dictionary is
().
The method used to add a new key-value pair to a dictionary is
().
What method do you use to remove a key-value pair from a dictionary?
How can you remove a key-value pair from a dictionary?
What does the method 'keys()' do in Python?
Dictionary Methods
What is the output of the following code?
dict = {'a': 1, 'b': 2, 'c': 3}
print(len(dict))
Which of the following is NOT a valid key type for a dictionary?
Dictionary Comprehension
What does the method 'items()' do in Python?
If you try to access a key that does not exist in a dictionary, it will result in a(n)
.
How do you add a new key-value pair to an existing dictionary?
Value
What happens if you try to access a key that doesn't exist in a dictionary?
Which of the following methods returns a list of all the keys in a dictionary?
Which of the following is NOT a valid key type for a Python dictionary?
Clear
Get
A Python dictionary cannot have two keys with the
name.
Immutable