Page Contents

## Interview Content

- C Programming Coding Questions
- C Pattern Programming Questions
- C Programming Interview Questions
- Java Programming Coding Questions
- Java Pattern Programming Questions
- Java Programming Interview Questions
- Python Programming Coding Questions
- Python Pattern Programming Questions
- Python Programming Interview Questions
- SQL Interview Questions

# Armstrong number program in python with explanation

**Ans: **

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 :

## What is Armstrong Number?

- 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

```
i=0
result=0
n = int(input("please give a number : "))
number1 = n
temp = n
while n!=0:
n = (n//10)
i=i+1;
while number1!=0:
n=number1%10
result=result+pow(n,i)
number1=number1//10
if temp==result:
print("number is armstrong")
else:
print("number is not armstrong")
```

**Output:**

##### Latest Uploads on Website

- AVL Tree with explanation
- Radix sort algorithm explanation with example
- Quick Sort Algorithm with explanation
- Bubble sorting algorithm with Bubble sort program in C
- Insertion sort algorithm and program in C
- Selection Sort Algorithm and Program in C
- Linear probing technique explanation with example
- Collision in Hashing and Collision resolution technique
- Hashing in data structure with its types
- Binary search tree operations with Program
- Binary search tree in data structure
- Binary search algorithm in data structure with explanation
- linear search in data structure with Algo and Program