Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


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
  1. Get the user input
  2. If the integer value is greater than 0, number is Positive
  3. If the integer value is lesser than 0, number is Negative
  4. 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  

Prev Next