ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(sum(map(int, str(2 ** 100))))
  1. A. 124
  2. B. 115
  3. C. 100
  4. D. 2

Correct answer: B. 115

Converting 2**100 to a string gives its decimal digits, and summing their integer values gives the digit sum 115. The number has 31 digits, so this stays within the int-to-str limit.

More Python Programming questions

Exams that ask this topic