Skip to content
Related Articles

Related Articles

Python-Quizzes | Python Dictionary Quiz | Question 20

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

Question 20:Find the output of the following program:

a = {} 
a[1] = 1
a['1'] = 2
a[1]= a[1]+1
count = 0
for i in a: 
    count += a[i] 

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

Answer: (B)

Explanation: The above piece of code basically finds the sum of the values of keys.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!