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)
- A. False 45 0
- B. True 45 9
- C. True 36 0
- 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
- What is printed? python print('a' 3 < 'b', 'a' 3 < 'aa', 'aaa' > 'aab', 'aa' + 'b' > 'aab')
- What is printed? python x = 5 print(x // 2 2 == x, x / 2 2 == x, 5 / 2 == 2.5, 5 // 2.0 == 2)
- What is printed? python print(bytes('é', 'utf-8'), 'é'.encode('latin-1'), len('é'.encode('latin-1')) == len('é'.encode('utf-8')))
- What is printed? python print(round(-0.5), round(0.5), round(1.5), round(-1.5), round(2.5))
- What is printed? python x = [3, 1, 2] print(sorted(x, reverse=True)[:2], x[::-1][1:], list(reversed(sorted(x))))
- What is printed? python print('%08.2f' % -1.5, '%+08d' % 42, '%-+5d|' % 7, '%x' % -255)