Which of the following data types in Python is used to store key-value pairs?
Select an option to see the answer and solution.
What method is used to check if a key exists in a dictionary, and if not, add it with a default value?
Select an option to see the answer and solution.
What does the len() function do when applied to a dictionary?
Select an option to see the answer and solution.
In Python, how can you get a list of all key-value pairs in a dictionary?
Select an option to see the answer and solution.
What is the purpose of the dict() constructor in Python?
Select an option to see the answer and solution.
Which method is used to remove a key-value pair from a dictionary?
Select an option to see the answer and solution.
In Python, how can you check if a key exists in a dictionary?
Select an option to see the answer and solution.
What method is used to update the values of a dictionary with the values from another dictionary?
Select an option to see the answer and solution.
What is the purpose of the keys() method for dictionaries?
Select an option to see the answer and solution.
Which method is used to get a list of all values in a dictionary?
Select an option to see the answer and solution.
In Python, how can you remove all key-value pairs from a dictionary?
Select an option to see the answer and solution.
What is the purpose of the items() method for dictionaries?
Select an option to see the answer and solution.
Which method is used to create a shallow copy of a dictionary?
Select an option to see the answer and solution.
What is the purpose of the clear() method for dictionaries?
Select an option to see the answer and solution.
What is the purpose of the fromkeys() method for dictionaries?
Select an option to see the answer and solution.
In Python, how can you get a list of all keys in a dictionary?
Select an option to see the answer and solution.
What is the purpose of the popitem() method for dictionaries?
Select an option to see the answer and solution.
What is the output of the following code:
my_dict = {'a': 1, 'b': 2}
print(my_dict['a'])
Select an option to see the answer and solution.
How can you add a new key-value pair to a dictionary in Python?
Select an option to see the answer and solution.
In Python, how can you create an empty dictionary?
Select an option to see the answer and solution.