Count odd numbers in set Dry Run in PYTHON

Count odd numbers in 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.

Count odd numbers in set Program Code

# Count odd numbers in set
numbers = {17, 24, 39, 42, 51, 68, 73, 86, 95}
print("Set:", numbers)

odd_count = 0
odd_list = []
for num in numbers:
    if num % 2 != 0:  # or num % 2 == 1
        odd_count += 1
        odd_list.append(num)

print(f"Odd numbers count: {odd_count}")
print(f"Odd numbers: {odd_list}")

View the complete Sets programs page.

Program Console Count odd numbers in set Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.