Check Whether a Number is Positive, Negative, or 0 in Python

(Last Updated On: 12/12/2022)

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

# Check Whether a Number is Positive, Negative, or Zero in Python
# accept input from user
num = float(input("Enter any number: "))

# using if condition to verify number type
if num > 0:
   print("Positive number")
elif num == 0:
   print("Zero")
else:
   print("Negative number")

Output:

Enter any number: -9
Negative number
Enter any number: 5
Positive number
Enter any number: 0
Zero

Leave a Reply

Your email address will not be published. Required fields are marked *