Answer to Question #232817 in Python for harry

Question #232817

Make a program which accepts a 3 digit number from user and check & confirms whether it is

an Armstrong number or not. Proper message should be displayed as the result.

Interface should be attractive and Numbers should be between 100 - 999.

Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself.


1
Expert's answer
2021-09-03T03:51:47-0400
while True:
    n = input('Enter number between 100 and 999: ')
    if n.isdigit() and 99 < int(n) < 1000:
        break
    else:
        print('Error: wrong input!')
if int(n) == sum([int(d) ** 3 for d in n]):
    print(n, 'is Armstrong number!')
else:
    print('Sorry,', n, 'isn\'t Armstrong number!')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS