Count positive and negative numbers (stop at 0) Dry Run in PYTHON

Count positive and negative numbers (stop at 0) is an interactive PYTHON dry run visualizer from the While 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 (stop at 0) Program Code

# Count positive and negative numbers
pos_count = 0
neg_count = 0
num = int(input("Enter a number (0 to stop): "))

while num != 0:
    if num > 0:
        pos_count += 1
    else:
        neg_count += 1
    num = int(input("Enter another number (0 to stop): "))

print(f"Positive numbers: {pos_count}")
print(f"Negative numbers: {neg_count}")

View the complete While programs page.

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