Python-Quizzes | Python Dictionary Quiz | Question 20
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]
print (count)
|
(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
Last Updated :
17 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...