Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program To Check If a Given Number is Amstrong number or Not


In this example shows, how to check the given number is Amstrong Number or Not.

Here the example to check the given number is amstrong number or not using if,else statement.
Example.py
num = int(input("Enter a number: "))
a=num//100
b=(num//10)%10
c=num%10
r=(a**3)+(b**3)+(c**3);
if r == num:
   print(num,"is an Armstrong number")
else:
   print(num,"is not an Armstrong number")

Output 1

Enter the Number : 153
153 is an Armstrong number 

Output 2

Enter the Number : 273
273 is not an Armstrong number

Prev Next