ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(len(str(float(10**16))), str(10**16 * 1.0), len(str(10**16)))
- A. 5 1e+16 17
- B. 17 1e+16 17
- C. 5 10000000000000000.0 17
- D. 5 1e+16 16
Correct answer: A. 5 1e+16 17
str of a float at 1e16 switches to exponent form, so the text is 1e+16 with five characters. The int 10**16 has 17 digits, which is why the two lengths differ.
More Python Programming questions
- What is printed? python print(0.1 + 0.7 == 0.8, 0.8 - 0.7, 0.3 / 0.1, int(0.3 / 0.1))
- What is printed? python print(1.0 == 1, 1.5 // 0.5, 1.5 % 0.4, 2.0 -1074 > 0, 2.0 -1075 == 0)
- What is printed? python print(float.fromhex('0x1p-2'), 0.25 == float.fromhex('0x1p-2'), float.fromhex('0x1.8p1'))
- What is printed? python print(divmod(10, 3)[::-1], divmod(-10, 3)[::-1], divmod(10, -3)[::-1])
- What is printed? python print(-5 % 3 == 1, 5 % -3 == -1, -5 // -3, 5 // -3)
- What is printed? python s = 'a-bc d' print(s.replace('-', ' ').replace('', ' ').split(), s.translate({45: None}))