ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

What is printed?
print(hash(1.5) == hash(3/2), hash(True) == hash(1), {0: 'x', False: 'y'}, len({1: 'a', True: 'b', 1.0: 'c'}))
  1. A. True False {0: 'x'} 1
  2. B. True True {0: 'y'} 1
  3. C. True True {0: 'x'} 3
  4. D. False True {0: 'y'} 1

Correct answer: B. True True {0: 'y'} 1

Equal numbers hash equal, so the two hash checks are True. False equals 0, so it overwrites the value for key 0 but keeps the original key object. 1, True and 1.0 are one key.

More Python Programming questions

Exams that ask this topic