Part of the series

Several example codes

~1 min read • Updated Oct 13, 2025

Program Overview

This Python program reads a list of numbers and classifies each one as either positive, negative, or zero.


Python Code:


def categorize_numbers(numbers: list[float]):
    for num in numbers:
        if num > 0:
            print(f"{num} → Positive")
        elif num < 0:
            print(f"{num} → Negative")
        else:
            print(f"{num} → Zero")

# Read input from user
raw_input = input("Enter numbers separated by space: ")
numbers = list(map(float, raw_input.strip().split()))
categorize_numbers(numbers)

Sample Output:


Input: 5 -3 0 12.5 -0.7  
Output:  
5.0 → Positive  
-3.0 → Negative  
0.0 → Zero  
12.5 → Positive  
-0.7 → Negative

Written & researched by Dr. Shahin Siami