Python-Quizzes | Python Dictionary Quiz | Question 16

Question 16:Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

numberGames = {} 
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
  
sum = 0
for k in numberGames: 
    sum += numberGames[k] 
  
print (len(numberGames) + sum)

chevron_right


(A) 33
(B) 12
(C) 10
(D) 8


Answer: (A)

Explanation: Tuples can be used for keys into dictionary. The tuples can have mixed length and the order of the items in the tuple is considered when comparing the equality of the 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.