Write a python program to check if a given 3-digit number
X is an Armstrong number or not. Note: A number is an Armstrong number if the number is equal to the sum of the Nth power of its digits.
1
Expert's answer
2021-07-09T14:19:29-0400
try:
n = int(input('n = '))
if n <= 100or n > 999:
raise ValueError
p = len(str(n))
s = 0for i inrange(p):
s += int(str(n)[i])**p
if s == n:
print(f'{n} is an Armstrong number')
else:
print(f'{n} is not an Armstrong number')
except ValueError:
print('incorrect inpur')
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Dear kaavya the code works well
unable to get the right output. Few errors are araising like in the above code s is not defined....