Check if a number is an Armstrong number Dry Run in PYTHON

Check if a number is an Armstrong number is an interactive PYTHON dry run visualizer from the For programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Check if a number is an Armstrong number Program Code

# Armstrong number: 153 = 1³ + 5³ + 3³ = 153
num = int(input("Enter a number: "))
original = num
sum_of_powers = 0

# Count digits
num_str = str(num)
num_digits = len(num_str)

# Calculate sum of digits raised to power
for digit in num_str:
    sum_of_powers += int(digit) ** num_digits

if sum_of_powers == original:
    print(f"{original} is an Armstrong number")
else:
    print(f"{original} is NOT an Armstrong number")

View the complete For programs page.

Program Console Check if a number is an Armstrong number Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.