Count positive and negative numbers Dry Run in PYTHON

Count positive and negative numbers 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 positive and negative numbers Program Code

# Count positive and negative numbers in set
numbers = {15, -3, 28, -7, 0, -12, 45, -9, 33, -21, 10}
print("Set:", numbers)

pos_count = 0
neg_count = 0
zero_count = 0
pos_list = []
neg_list = []

for num in numbers:
    if num > 0:
        pos_count += 1
        pos_list.append(num)
    elif num < 0:
        neg_count += 1
        neg_list.append(num)
    else:
        zero_count += 1

print(f"Positive: {pos_count} → {pos_list}")
print(f"Negative: {neg_count} → {neg_list}")
print(f"Zeros: {zero_count}")

View the complete Sets programs page.

Program Console Count positive and negative numbers Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.