Test Index
CBSE Class 12 Computer Science 2026 Paper Compartment
© examsnet.com
Question : 9 of 37
Marks:
+1,
-0
Which of the following is true about
clear() in Python ?
Solution:
Concept:
D.clear() is a dictionary method that removes all key-value pairs; the dictionary object still exists and becomes {}.Explanation:D = {'a': 1, 'b': 2}D.clear()print(D) # {}(A) Deleting the dictionary itself is done by del D, not clear().(C) clear() is a method, called as D.clear(); clear(D) gives a NameError.(D) The method does exist.Answer:Option B (It deletes all items of the dictionary resulting in an empty dictionary.)© examsnet.com
Go to Question: