🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)
  1. A.True
  2. B.False
  3. C.9474
  4. 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 →