Test Index
Python Revision Tour
© examsnet.com
Question : 92 of 102
Marks:
+1,
-0
Given the following dictionary
Day={1:"Monday", 2: "Tuesday", 3: "Wednesday"}Which statement will return "Tuesday".[CBSE 2023 Compartment]
Solution:
Concept:
dict.pop(key) removes the item with that key and returns its value. It needs a key; pop() without an argument gives a TypeError, and a key that is not present gives a KeyError.Explanation:"Tuesday" is stored against the key 2, so Day.pop(2) returns "Tuesday".Day.pop(1) returns "Monday"; Day.pop("Tuesday") fails because "Tuesday" is a value, not a key.Answer:Option B (Day.pop(2))© examsnet.com
Go to Question: