ProgrammingHardGATE CS · Product-company placement

What is printed?

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

Correct answer: D. True True False 3

`not` has lower precedence than comparisons, so `not 1 == 2` is not (1 == 2) = True. `not (1==2) is True` is not (False is True) = True. (not 1) is False, which is not 2. bools add as 0/1.

More Python Programming questions

Exams that ask this topic