ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(sum(map(int, '123456789')) == 45, sum(map(int, str(9**9))), 9**9 % 9)
  1. A. False 45 0
  2. B. True 45 9
  3. C. True 36 0
  4. D. True 45 0

Correct answer: D. True 45 0

The digits 1 to 9 add to 45, and 9**9 = 387420489 has the digit sum 45 as well. A number that is a multiple of 9 has a digit sum that is a multiple of 9, and 9**9 is divisible by 9.

More Python Programming questions

Exams that ask this topic