ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: B. True x None

Sets and dicts look up keys by hash and equality, so 1.0 finds the key 1. The string key '1' is not equal to the int 1, so get returns None.

More Python Programming questions

Exams that ask this topic