Check if Number is Positive, Negative, or Zero

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

BeginnerPhase 1 - Level 1: Simple ConditionsExample 1 of 10
check-if-number-is-positive-negative-or-zero.py
1# Take a number as input
2num = float(input("Enter a number: "))
3
4# Check if positive, negative, or zero
5if num > 0:
6 print("Positive")
7elif num < 0:
8 print("Negative")
9else:
10 print("Zero")

Output

Enter a number: 5
Positive

Enter a number: -3
Negative

Enter a number: 0
Zero

What's going on

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"