While-else clause demonstration Dry Run in PYTHON

While-else clause demonstration 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.

While-else clause demonstration Program Code

# While-else executes else when loop completes normally
num = int(input("Enter a number to find factors: "))
i = 2
found = False

while i <= num // 2:
    if num % i == 0:
        print(f"{num} is divisible by {i}")
        found = True
        break
    i += 1
else:
    print(f"{num} is a prime number!")

if found:
    print(f"{num} is composite (not prime)")

View the complete While programs page.

Program Console While-else clause demonstration Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.