Question 1 of 25
Hints left: 3
Q1
What method is used to update the values of a dictionary with the values from another dictionary?
Q2
What is the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} my_dict.pop('b') print(my_dict)
Q3
What is the purpose of the values() method for dictionaries?
Q4
Which method is used to get a list of all values in a dictionary?
Q5
In Python, how can you remove all key-value pairs from a dictionary?
Q6
In Python, how can you check if a key exists in a dictionary?
Q7
What is the purpose of the fromkeys() method for dictionaries?
Q8
In Python, how can you create an empty dictionary?
Q9
What is the output of the following code: my_dict = {'a': 1, 'b': 2} print(my_dict['a'])
Q10
Which method is used to create a shallow copy of a dictionary?
Q11
What is the output of the following code: my_dict = {'a': 1, 'b': 2} new_dict = my_dict.copy() print(new_dict)
Q12
What is the purpose of the clear() method for dictionaries?
Q13
What will be the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} my_dict.items() print(my_dict)
-
A
-
B
-
C
-
D
Q14
What is the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} print(my_dict.get('d', 0))
Q15
What is the purpose of the items() method for dictionaries?
Q16
What is the purpose of the popitem() method for dictionaries?
Q17
In Python, how can you get a list of all keys in a dictionary?
Q18
What is the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} my_dict.values() print(my_dict)
Q19
In Python, how can you get a list of all key-value pairs in a dictionary?
Q20
Which method is used to remove a key-value pair from a dictionary?
Q21
What will be the output of the following code: my_dict = {'a': 1, 'b': 2} my_dict['c'] = 3 print(my_dict)
Q22
What is the purpose of the dict() constructor in Python?
Q23
What is the output of the following code: my_dict = {'a': 1, 'b': 2} del my_dict['b'] print(my_dict)
Q24
How can you add a new key-value pair to a dictionary in Python?
Q25
What is the purpose of the keys() method for dictionaries?