ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: C. False True True

in, == and < are all comparison operators, so they chain like a < b < c. 1 in n == True means (1 in n) and (n == True); a list never equals True, so the result is False. With brackets it is simply True == True. 0 < 1 in n means (0 < 1) and (1 in n), both True.

More Python Programming questions

Exams that ask this topic