What is the purpose of the popitem() method for dictionaries?
A. Removes and returns the last key-value pair in the dictionary
B. Removes and returns a random key-value pair from the dictionary
C. Removes and returns the first key-value pair in the dictionary
D. Removes and returns the specified key-value pair from the dictionary
Answer: Option B
Which of the following data types in Python is used to store key-value pairs?
A. Dictionary
B. List
C. Tuple
D. Set
A. setdefault()
B. addkey()
C. insert()
D. newkey()
What does the len() function do when applied to a dictionary?
A. Returns the number of key-value pairs in the dictionary
B. Returns the sum of all values
C. Returns the length of the longest key
D. Returns the length of the longest value
In Python, how can you get a list of all key-value pairs in a dictionary?
A. items()
B. get_items()
C. all_items()
D. list_items()
Join The Discussion