Python Program to Check if a Number is Positive, Negative or 0


Example

									
num = float(input("Enter a number: "))
if num > 0:
   print("Positive number")
elif num == 0:
   print("Zero")
else:
   print("Negative number")


Output

Enter a number: 2
Positive number


Explanation

A number is positive if it is greater than zero. We check this in the expression of if. If it is False, the number will either be zero or negative. This is also tested in subsequent expression.