ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(1 < 2 < 3 != 4, (1 < 2) < 3, 2 ** -1, 2 ** 0.5 ** 2)
  1. A. True True 0.5 2.0000000000000004
  2. B. False True 0.5 1.189207115002721
  3. C. True True 0.5 1.5
  4. D. True True 0.5 1.189207115002721

Correct answer: D. True True 0.5 1.189207115002721

Comparisons chain, so 1 < 2 < 3 != 4 is True. ** is right-associative, so 2 ** 0.5 ** 2 is 2 ** 0.25. Parsing it as (2 ** 0.5) ** 2 gives 2.0000000000000004.

More Python Programming questions

Exams that ask this topic