Separate even and odd numbers from set Dry Run in PYTHON

Separate even and odd numbers from set is an interactive PYTHON dry run visualizer from the Sets 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.

Separate even and odd numbers from set Program Code

# Separate even and odd numbers
numbers = {14, 27, 42, 59, 68, 81, 90, 33}
print("Original set:", numbers)

even = {num for num in numbers if num % 2 == 0}
odd = {num for num in numbers if num % 2 != 0}

print(f"Even numbers: {even}")
print(f"Odd numbers: {odd}")

# Manual method
even_manual = set()
odd_manual = set()
for num in numbers:
    if num % 2 == 0:
        even_manual.add(num)
    else:
        odd_manual.add(num)
print(f"\nManual - Even: {even_manual}")
print(f"Manual - Odd: {odd_manual}")

View the complete Sets programs page.

Program Console Separate even and odd numbers from set Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.