Filter prime numbers from a list Dry Run in PYTHON

Filter prime numbers from a list is an interactive PYTHON dry run visualizer from the Special 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.

Filter prime numbers from a list Program Code

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

numbers = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 17, 19]

primes = list(filter(is_prime, numbers))

print(f"Original: {numbers}")
print(f"Prime numbers: {primes}")

View the complete Special programs page.

Program Console Filter prime numbers from a list Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.