← Quiz: Python Interview Programs: all 13 questions
Quiz: Python Interview Programs · Question 13 of 13
What does this print? (code)
What does this print?
n = 9474
digits = str(n)
print(sum(int(d) ** len(digits) for d in digits) == n)
- A.True
- B.False
- C.9474
- D.An error
Answer & explanation
Correct answer: True
9474 has 4 digits and 9⁴ + 4⁴ + 7⁴ + 4⁴ = 6561 + 256 + 2401 + 256 = 9474, so it is an Armstrong number.
Can you get the rest right without peeking?
Take the timed Quiz: Python Interview Programs quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →