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

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz