ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(len(str(float(10**300))), str(float(10**22))[:4], float(10**22) == 10**22)
- A. 6 1e+2 False
- B. 7 1e+22 True
- C. 6 1e+2 True
- D. 6 1e+3 True
Correct answer: C. 6 1e+2 True
float(10**300) prints as 1e+300, which has six characters. str(float(10**22)) is 1e+22, and its first four characters are 1e+2. 10**22 is exactly representable, so the comparison is True.
More Python Programming questions
- What is printed? python print(10 // 3, 10 % 3, divmod(10, 3), (10 // 3) 3 + 10 % 3)
- What is printed? python print([1, 2, 3].index(2), 'abc'.index('bc'), (1, 2).index(2), [1, 2, 3].count(4))
- What is printed? python print(float('-0') == 0, str(float('-0')), str(0 -1.0), 0.0 -1)
- What is printed? python print(1 < 2 < 3 < 4 == 4.0, 4 == 4.0 != 5, 1 < 3 > 2 < 2)
- What is printed? python print(oct(0o17 + 0b11), 0x10 | 0o7, 10 + 0x1)
- What is printed? python print('x'.center(4, '-') + '|', '7'.zfill(3) + '|', '-7'.zfill(4))