ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(str(1e100)[:6], len(str(1e100)), 1e100 == 10**100)
- A. 1e+100 6 False
- B. 1e+100 6 True
- C. 1e+100 7 False
- D. 1000000 6 False
Correct answer: A. 1e+100 6 False
str of 1e100 uses exponent form, so the text is 1e+100 with six characters. The float 1e100 is not exactly 10**100, so the comparison with the int is False.
More Python Programming questions
- What is printed? python print(divmod(-1, 1020), divmod(1020, -1))
- What is printed? python print(int(1e20) == 1020, int(1e20 + 1) == 1020 + 1, int(1e20) - 1020)
- What is printed? python print(max(float('nan'), 1.0), min(float('nan'), 1.0), max(1.0, float('nan')))
- What is printed? python print(len(str(3100)), str(3100)[-1], str(3100)[:3])
- What is printed? python s = 'x' t = s s = s + 'y' print(t, s, t is s)
- What is printed? python print(''.join(map(chr, [72, 105])), ord('A') > 127, len('ab'.encode('utf-8')))