To check whether given number is an Armstrong number or not an Armstrong number in python, you have to ask from user to enter a number to check for Armstrong number as shown in the program given below.
Following python program ask from user to enter any number to check for Armstrong number:
# Python Program - Check Armstrong Numbers while True: print("Enter 'x' for exit.") num = input("Enter any number: ") if num == 'x': break else: number = int(num) tot = 0 temp = number while temp > 0: dig = temp % 10 tot += dig ** 3 temp //= 10 if number == tot: print(number,"is an Armstrong Number.\n") else: print(number,"is not an Armstrong Number.\n")
Here is the sample run of the above Python program shows how to check whether a number is an Armstrong number or not:
You may also like to learn or practice the same program in other popular programming languages: