Python-Quizzes | Python Dictionary Quiz | Question 20

Question 20:Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


(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
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.