Below is the program to check whether the entered number is Armstrong or not.


num = int(input("Enter Your Number: "))
sum = 0

temp = num # store value to compare later on 
while temp > 0:
   digit = temp % 10
   sum =sum + digit ** 3
   temp =temp // 10

if num == sum:
   print("Congrats !! "+str(num)+" is an Armstrong number.")
else:
   print("Oops !!"+str(num)+"is not an Armstrong number")
image 15 - https://codeconfig.in

Output:

image 16 - https://codeconfig.in
image 17 - https://codeconfig.in

Comments are closed.

Explore More

Python 10 Programs for Beginners

Program 1:Write a program to create a 2D array using NumPy. Output: Program 2: Write a program to convert a python list to a NumPy array. Output: Program 3: Write a program to create matrix of 3×3 from 11 to 30. Output: Program 4: Write a program to create a data frame to store data of candidates who appeared in

Find index of first occurrence when an unsorted array is sorted

Find index of first occurrence when an unsorted an array is sorted Given an unsorted an array and a number x, find an index of first occurrence of x when

Find sum non repeating distinct elements array

Find sum of non-repeating (distinct) elements in an array Given an integer an array with repeated elements, the task is to find the sum of all distinct elements in the