ProgrammingVery hardTCS NQT · Accenture

What is printed?

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

Correct answer: C. True True True False

Chained comparisons check each adjacent pair, so 1 == True == 1.0 holds, and 2 > 1 == True holds too. The last one needs 1 < 2 and 2 == True, but 2 is not equal to True.

More Python Programming questions

Exams that ask this topic