ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(sum(map(int, str(2**20))), len(str(3**50)), str(10**5)[::-1].count('0'))
  1. A. 31 23 5
  2. B. 30 24 5
  3. C. 31 24 4
  4. D. 31 24 5

Correct answer: D. 31 24 5

The digits of 2**20 = 1048576 sum to 31, and 3**50 has 24 digits. Reversing '100000' gives '000001', which has five zeros.

More Python Programming questions

Exams that ask this topic