ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

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

Correct answer: C. False 2.0000000000000004 1.189207115002721

The square root of 2 squared is 2.0000000000000004, not exactly 2. ** is right-associative, so 2 ** 0.5 ** 2 is 2 ** (0.5 ** 2) = 2 ** 0.25.

More Python Programming questions

Exams that ask this topic