ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(sum(int(c) for c in str(2**1000)), len(str(2**1000)))
- A. 1366 301
- B. 1365 302
- C. 1366 302
- D. 1368 302
Correct answer: C. 1366 302
2 to the power 1000 has 302 digits, and the digit sum of this number is 1366. Python integers keep every digit, so the conversion to str is exact.
More Python Programming questions
- What is printed? python print(len(set(str(i i) for i in range(10))), sorted([(-1) i i for i in range(6)]))
- What is printed? python print(list(map(round, [0.5, 1.5, 2.5, -0.5, -1.5])), list(map(int, [0.5, 1.5, 2.5, -0.5, -1.5])))
- What is printed? python print(max(['10', '9']), max(['10', '9'], key=len), sorted(['10', '9', '100'], key=lambda s: (len(s), s)))
- What is printed? python print(int(True) - ~True, 4 >> True, True << 3, True + True True)
- What is printed? python print('5' 3 > '10' 2, 5 3 > 10 2, '55' < '9', 55 < 9)
- What is printed? python print(float('inf') > 21000, -float('inf') < -(21000), float('inf') == float('inf') + 1)