Programming Examples

Python program to check whether given number is Armstrong or not


Write a program to input any number and to check whether given number is Armstrong or not.

Example:

Armstrong 153,

1^3+5^3 +3^3 =(1+125+27)=153

Solution

num=int(input("Enter any Number"))
sum=0
tmp=num
while num>0:
    digit=(num%10)
    sum=sum+digit**3
    num=num//10
if sum==tmp:
    print(tmp, " is Armstrong Number")
else:
    print(tmp, " is not Armstrong Number")
Output

Enter any Number153

153  is Armstrong Number

>>> 

========================

Enter any Number123

123  is not Armstrong Number

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad