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

Machine Learning Projects

Hey guys, in this blog we will see a Python Program to Check if a Number is Positive, Negative, or 0.

Code

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

num = input('Enter the number -> ')

num = float(num)

if num==0:
    print('You have entered 0')
elif num <0:
    print(f'{num} is a negative number')
else:
    print(f'{num} is a positive number')

Output

Enter the number -> 12
12 is a positive number
Enter the number -> -13
-13 is a negative number
Enter the number -> 0
You have entered 0

Here we are simply using if/else to check if the number is equal to 0, less than 0, or greater than 0.

Check out our other python programming examples

Leave a Comment

Your email address will not be published.