ProgrammingVery hardProduct-company MCQ pattern

What is printed?

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

Correct answer: C. True False True {1}

1 and 1.0 hash and compare equal, so the set and dict tests match. '1' is a different type from 1, so it is not found, and the set keeps only one of 1, True and 1.0.

More Python Programming questions

Exams that ask this topic