Separate even and odd numbers from tuple Dry Run in PYTHON

Separate even and odd numbers from tuple is an interactive PYTHON dry run visualizer from the Tuples 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 tuple Program Code

# Separate even and odd numbers from tuple
numbers = (16, 9, 25, 48, 37, 22, 11, 64, 53, 30, 43)
print("Original tuple:", numbers)

even = tuple(num for num in numbers if num % 2 == 0)
odd = tuple(num for num in numbers if num % 2 != 0)

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

# Using manual loop
even_manual = []
odd_manual = []
for num in numbers:
    if num % 2 == 0:
        even_manual.append(num)
    else:
        odd_manual.append(num)
print(f"\nManual - Even: {tuple(even_manual)}")
print(f"Manual - Odd: {tuple(odd_manual)}")

View the complete Tuples programs page.

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