ProgrammingVery hardGATE CS · Product-company placement

What is printed?

What is printed?
x = 5
print(1 < x < 10 > 3 != 4, 3 > 2 > 1 == True, (3 > 2) > (1 == True), 0 == 0 in [0])
  1. A. True True False True
  2. B. True False False True
  3. C. True True True True
  4. D. False True False False

Correct answer: A. True True False True

Chains expand pairwise with `and`: 3 > 2 > 1 == True means (3>2) and (2>1) and (1==True), all True. The parenthesised version compares True > True, which is False. `0 == 0 in [0]` is (0 == 0) and (0 in [0]).

More Python Programming questions

Exams that ask this topic