ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: C. True False

Chained comparisons check each adjacent pair. The first chain holds because 5 <= 5 < 6 and 6 != 7. The second fails at 2 > 3.

More Python Programming questions

Exams that ask this topic