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)
- A. True 2.0 1.5
- B. False 2.0 1.189207115002721
- C. False 2.0000000000000004 1.189207115002721
- 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
- What is printed? python print('%.2f' % 1.005, '%.2f' % 1.015, '%.2f' % 1.025, '%.1f' % 0.25)
- What is printed? python s = 'abc' t = s s += 'd' print(t, s, t is s, id(s) == id(t))
- What is printed? python def tosigned(v): return v - (1 << 32) if v >= 1 << 31 else v print(tosigned(0xFFFFFFFE), tosigned(0x7FFFFFFF)…
- What is printed? python s = 'hello world' print(s.capitalize(), s.title().swapcase(), s.center(15, ''), s.zfill(13))
- What is printed? python print(divmod(-7, 2), divmod(7, -2.0), 7 // -2.0, -7 % 2.5)
- What is printed? python x = -17 print(x // 5, x % 5, divmod(x, -5), x.mod(5))