Armstrong number program in python with explanation

Welcome back, In this tutorial we are going to learn how to write a program in python to check a given input number is Armstrong or not?

So before moving directly on the writing program I will recommend you please first know :

  • It is a number which is equal to the sum of cube of its digits.
  • For eg: 153, 370 etc.

Lets see it practically by calculating it,

Suppose I am taking 153 for an example 

First calculate the cube of its each digits

  1^3 = (1*1*1) = 1

  5^3 = (5*5*5) = 125

  3^3= (3*3*3) = 27

Now add the cube 

  1+125+27 = 153

It means 153 is an Armstrong number.


Ok, Then move on the program when you have cleared concept 🙂

Program to check a number is Armstrong or not in python programming language

n = int(input("please give a number : "))
number1 = n
temp = n
while n!=0:
    n = (n//10)
while number1!=0:
if temp==result:
    print("number is armstrong")
    print("number is not armstrong") 


armstrong program in python

Leave a Comment