Quiz Complete, well Done!
What is the output of the following code?
dict = {'a': 1, 'b': 2, 'c': 3}
print(len(dict))
A
is a collection of key-value pairs.
How can you access the value associated with a specific key in a dictionary?
Length
The function used to check if a key is present in a dictionary is
().
Which of the following is NOT a valid key type for a Python dictionary?
What is the output of the following code?
dict = {'a': 1, 'b': 2, 'c': 3}
print('a' in dict)
Key
What is the syntax for creating a dictionary in Python?
What method do you use to remove a key-value pair from a dictionary?
Which of the following is a valid way to create an empty dictionary in Python?
The method used to remove a key-value pair from a dictionary is
().
How do you add a new key-value pair to an existing dictionary?
Dictionary
Value
What does the method 'keys()' do in Python?
What is the output of the following code?
dict = {'a': 1, 'b': 2, 'c': 3}
print(dict.get('d', 'Not found'))
A key in a Python dictionary must be of a(n)
type.
What happens if you try to access a key that does not exist in a dictionary using the 'get' method?