Programming Examples

Implement Python Script to check given number is Armstrong or not.


Implement Python Script to check given number is Armstrong or not.

Solution

num = int(input("Enter a number: "))
temp = num
sum = 0
digits = len(str(num))

while temp > 0:
    digit = temp % 10
    sum += digit ** digits
    temp //= 10

if sum == num:
    print(num, "is an Armstrong number.")
else:
    print(num, "is not an Armstrong number.")
▶ RUN

Output/ Explanation:

Enter a number: 153

153 is an Armstrong number.

Latest Current Affairs 2026 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad