Function to check prime number Dry Run in PYTHON

Function to check prime number is an interactive PYTHON dry run visualizer from the Functions 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.

Function to check prime number Program Code

def is_prime(n):
    """Return True if n is prime, False otherwise"""
    if n <= 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

num = 29
if is_prime(num):
    print(f"{num} is prime")
else:
    print(f"{num} is composite")

View the complete Functions programs page.

Program Console Function to check prime number Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.