Check if number is perfect number Dry Run in PYTHON

Check if number is perfect number is an interactive PYTHON dry run visualizer from the While 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 number is perfect number Program Code

# Perfect number = sum of proper divisors equals the number
num = int(input("Enter a number: "))
sum_divisors = 0
i = 1

while i <= num // 2:
    if num % i == 0:
        sum_divisors += i
    i += 1

if sum_divisors == num and num > 0:
    print(f"{num} is a perfect number")
else:
    print(f"{num} is NOT a perfect number")

View the complete While programs page.

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