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