ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(3 ** -1, 7 // 0.5, 2 ** 0.5 * 2 ** 0.5 == 2)
- A. 0.3 14.0 False
- B. 0.3333333333333333 3.5 False
- C. 0.3333333333333333 14.0 False
- D. 0.3333333333333333 14 True
Correct answer: C. 0.3333333333333333 14.0 False
A negative int exponent gives a float, 1/3. 7 // 0.5 is 14.0. The square root of 2 squared is 2.0000000000000004 in floating point.
More Python Programming questions
- What is printed? python print(float('%.2f' % 0.125), '%.3e' % 12345.678)
- What is printed? python print(int(str(2 70)[:5]), len(str(2 70)))
- What is printed? python print(list(range(10, 0, -4)), [sum(r) for r in [(1, 2), (3,)]])
- What is printed? python print(2 0.5 2 0.5, 2 0.5 2 0.5 == 2.0, round(2 0.5 2 0.5))
- What is printed? python print(min(map(str, [10, 9, 100])), sorted(['10', '9', '100']), sorted([10, 9, 100]))
- What is printed? python print(len([x for x in range(10) if x % 3 == 0]), sum(range(0, 10, 3)))