ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(len({1, 1.0, True, '1'}), len({'1', 1}), {1, 2} == {2.0, 1.0}, {0} == {False})
  1. A. 2 1 True True
  2. B. 2 2 True True
  3. C. 2 2 False True
  4. D. 3 2 True True

Correct answer: B. 2 2 True True

1, 1.0 and True are one set element, and '1' is a different element, giving two. Sets compare equal when their elements compare equal, and False equals 0.

More Python Programming questions

Exams that ask this topic