Here you will get python program to check armstrong number.

A number is said to be an armstrong number if sum of its digits raised to the power n is equal to itself. Here n is total digits in number.

For example 370 is armstrong number.

Here n = 3, so 3^{3 + }7^{3 }+ 0^{3 }= 27 + 343 + 0 = 370

## Python Program to Check Armstrong Number

num = int(input("enter a number: ")) length = len(str(num)) sum = 0 temp = num while(temp != 0): sum = sum + ((temp % 10) ** length) temp = temp // 10 if sum == num: print("armstrong number") else: print("not armstrong number")

**Output**

*enter a number: 370*

*armstrong number*

Comment below if you have any queries related to above program for armstrong number in python.

susmithacan we do without length.

RaghavYes we can do it without length.

AfrinWhat is meaning temp her?

Vanshikatemp is a variable which is temporarily storing the value of num

ChanduIt’s a temporary variable indicating as temp to store the values

Muskan MaheshwariTemp is just a variable,you can also use any other variable in place of temp as i, x

Atanutemp should pass more than zero or for positive integer/

satyamwhy do we add”!” symbol after temp

Tarun Sura“==” in programming this symbol means “is equal to” same way “=!” means “not equal to”

so if temp is not equal to 0 execute the below code.

ajith kumarcorrect

simranwhat is len in second line

Muskan Maheshwarilen is a function that is used for measuring the length of the number in given example

MujeebPython in rasy way

FarhanHow to write the same code using def function