Skip to content
Related Articles

Related Articles

Python-Quizzes | Python Dictionary Quiz | Question 24

Improve Article
Save Article
Like Article
  • Last Updated : 17 Sep, 2020

Question 24:Find the output of the following program:

dictionary = {1:'1', 2:'2', 3:'3'
del dictionary[1
dictionary[1] = '10'
del dictionary[2
print (len(dictionary) )

(A) 1
(B) 2
(C) 3
(D) 4

Answer: (B)

Explanation: The task of the ‘del’ function is to remove key-value pairs from a dictionary. Initially the size of the given dictionary was 3. Then the key value pair for key 1 is first removed and then added back with a new value. Then the key value pair for key 2 is removed. So, finally the size of the dictionary is 2.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!