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

www.ig‮fi‬tidea.com

Here's a Python program to check if a number is positive, negative or zero:

num = float(input("Enter a number: "))

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

In this program, we first ask the user to input a number using the input() function. The input is converted to a float using the float() function and stored in the num variable.

We then check if the number is greater than 0 using the > operator. If it is, we print "Positive number". If it's not, we check if it's equal to 0 using the == operator. If it is, we print "Zero". If it's neither greater than 0 nor equal to 0, it must be negative, so we print "Negative number".

Note that we use float() instead of int() to allow for the possibility of decimal numbers. If you only want to deal with integers, you can change the first line to num = int(input("Enter a number: ")).