Skip to content
Related Articles

Related Articles

Python-Quizzes | Python Dictionary Quiz | Question 16

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

Question 16:Find the output of the following program:




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)

(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
Recommended Articles
Page :

Start Your Coding Journey Now!