Count positive and negative numbers Dry Run in PYTHON

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

Count positive and negative numbers Program Code

# Count positive and negative numbers in tuple
numbers = (15, -3, 28, -7, 0, -12, 45, -9, 33, -21, 10)
print("Tuple:", 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 numbers: {pos_count} → {pos_list}")
print(f"Negative numbers: {neg_count} → {neg_list}")
print(f"Zeros: {zero_count}")

View the complete Tuples programs page.

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