ProgrammingModerateTCS NQT · Accenture

What is printed?

What is printed?
print(len({(1, 2): 'a', (2, 1): 'b', (1, 2): 'c'}))
  1. A. 3
  2. B. 1
  3. C. 0
  4. D. 2

Correct answer: D. 2

Keys (1, 2) and (2, 1) are different, and the second (1, 2) overwrites the first value, so the dict has two keys.

More Python Programming questions

Exams that ask this topic