ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
values = [2.0, 2, '2']
print(len(set(values[:2])), len(set(values)), values[0] == values[1] == 2)
  1. A. 2 2 True
  2. B. 1 2 True
  3. C. 1 3 True
  4. D. 1 2 False

Correct answer: B. 1 2 True

2.0 and 2 are the same set element, but the string '2' is different. The chained comparison checks 2.0 == 2 and 2 == 2, both True.

More Python Programming questions

Exams that ask this topic