Python Program to Check Whether a Number is Positive or Negative
In this example shows, how to check the given number is positive or negative.
Steps
- Get the user input
- If the integer value is greater than 0, number is Positive
- If the integer value is lesser than 0, number is Negative
- If the number is equal to 0, it shows Equal to zero
Here the example to check the given number is positive or negative using if,else statement.
Example.py
a = int(input("Enter the Number :")) if(a>0): print("Positive") elif(a<0): print("Negative") else: print("Equal to zero")
Output 1
Enter the Number : 10 Positive
Output 2
Enter the Number : -5 Negative