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
- First of all, we are simply taking input from the user.
- Converting it to float.
- And then simply use 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…