Quiz Complete, well Done!
What does the method 'keys()' do in Python?
The method used to get the value of a key in a dictionary without raising an error is
().
Pop
What is the output of the following code?
dict = {'a': 1, 'b': 2, 'c': 3}
print(dict.get('d', 'Not found'))
How do you add a new key-value pair to an existing dictionary?
What does the method 'values()' do in Python?
Copy
How do you add a new key-value pair to an existing dictionary?
Which of the following is NOT a valid key type for a dictionary?
In Python, dictionaries are denoted by enclosing a comma-separated pair of curly braces with
within.
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?
How can you remove a key-value pair from a dictionary?
What does the method 'values()' do in Python?
What is the output of the following code?
dict = {'a': 1, 'b': 2, 'c': 3}
for key in dict:
print(key)
The function used to check if a key is present in a dictionary is
().
Update
What happens if you try to access a key that does not exist in a dictionary?
What does the method 'items()' do in Python?
Length