ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(1 == 1.0 == True, {1: 'a'}.get(True))
  1. A. False a
  2. B. True None
  3. C. False None
  4. D. True a

Correct answer: D. True a

1, 1.0 and True compare equal, so the chained comparison is True. True hashes like 1, so the dict lookup with key True finds the value 'a'.

More Python Programming questions

Exams that ask this topic