1. Which of the following data types in Python is used to store key-value pairs? A. Dictionary B. List C. Tuple D. Set Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
2. What method is used to check if a key exists in a dictionary, and if not, add it with a default value? A. setdefault() B. addkey() C. insert() D. newkey() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
3. 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 Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
4. 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() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
5. What is the purpose of the dict() constructor in Python? A. Creates a new dictionary B. Converts a list to a dictionary C. Converts a tuple to a dictionary D. Converts a string to a dictionary Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
6. Which method is used to remove a key-value pair from a dictionary? A. pop() B. remove() C. delete() D. discard() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
7. In Python, how can you check if a key exists in a dictionary? A. in keyword B. exists() C. contains() D. check() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
8. What method is used to update the values of a dictionary with the values from another dictionary? A. update() B. set() C. add() D. merge() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
9. What is the purpose of the keys() method for dictionaries? A. Returns a list of all keys in the dictionary B. Returns a list of all values in the dictionary C. Returns a list of all items in the dictionary D. Returns a list of all keys and values in the dictionary Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
10. Which method is used to get a list of all values in a dictionary? A. values() B. get_values() C. all_values() D. list_values() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board