Report Bug

Qus

What will be the output of the following Python code?

  1.   numberGames = {}
  2.   numberGames[(1,2,4)] = 8
  3.   numberGames[(4,2,1)] = 10
  4.   numberGames[(1,2)] = 12
  5.   sum = 0
  6. for k in numberGames:
  7.       sum += numberGames[k]
  8.   print len(numberGames) + sum
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. 30
B. 24
C. 33
D. 12


Solution
C. 33



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.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad