Question 17

Consider the following dictionary: Num = {10 : 'Ten', 100 : 'Hundred', 10: 'Decimal'}

Consider the following dictionary: Num = {10 : 'Ten', 100 : 'Hundred', 10: 'Decimal'} What shall be the output of print (Num)?
  1. A{10 : 'Ten', 100 : 'Hundred', 10 : 'Decimal'}
  2. B{10 : 'Ten', 100 : 'Hundred'}
  3. C{10 : 'Decimal', 100 : 'Hundred'}
  4. DError
Show answerHide answer

Correct answer: (C) {10 : 'Decimal', 100 : 'Hundred'}

Explanation

Dictionary keys must be unique. The second 10 overwrites the first value but keeps the key's original position, giving {10: 'Decimal', 100: 'Hundred'}.

From DSSSB TGT Computer Science Practice Set 4

This is question 17 of DSSSB TGT Computer Science Practice Set 4. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.