The Wayback Machine - http://web.archive.org/web/20220125175401/https://www.geeksforgeeks.org/python-quizzes-python-dictionary-quiz-question-23/
Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python-Quizzes | Python Dictionary Quiz | Question 23

  • Last Updated : 17 Sep, 2020

Question 23:Find the output of the following program:




dictionary = {} 
dictionary[1] = 1
dictionary['1'] = 2
dictionary[1] += 1
  
sum = 0
for k in dictionary: 
    sum += dictionary[k] 
  
print (sum)

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


Answer: (A)

Explanation: In the above dictionary, the key 1 enclosed between single quotes and only 1 represents two different keys as one of them is integer and other is string. So, the output of the program is 4.

Quiz of this Question

Image

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!