ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print(hash(-1), hash(-2), hash(-1) == -2, hash(1) == hash(1.0))
  1. A. -2 -2 True True
  2. B. -1 -2 True True
  3. C. -2 -2 False True
  4. D. -2 -1 True True

Correct answer: A. -2 -2 True True

CPython reserves -1 as an internal error code for hashing, so hash(-1) is -2. hash(-2) is also -2, and equal numbers such as 1 and 1.0 always share a hash.

More Python Programming questions

Exams that ask this topic