Check if Number is Positive, Negative, or Zero

Take a number and print whether it's positive, negative, or zero.

Logic BuildingBeginner
Logic Building
# Take a number as input
num = float(input("Enter a number: "))

# Check if positive, negative, or zero
if num > 0:
    print("Positive")
elif num < 0:
    print("Negative")
else:
    print("Zero")

Output

Enter a number: 5
Positive

Enter a number: -3
Negative

Enter a number: 0
Zero

This program demonstrates basic conditional logic using if-elif-else.

Key Concepts:

  • Use > to check if number is greater than 0 (positive)
  • Use < to check if number is less than 0 (negative)
  • Use else for the case when number equals 0

Logic Flow:

  1. Check if num > 0 → Print "Positive"
  2. Else if num < 0 → Print "Negative"
  3. Else (num == 0) → Print "Zero"