Python Program to Check Whether a Number is Positive or Negative or zero

Given a number. The task is to check whether the number is positive or negative or zero.

Examples:

Input: 5
Output: Positive

Input: -5
Output: Negative

Approach:

We will use the if-elif statements in Python. We will check whether the number is greater than zero or smaller than zero or equal to zero.

Below is the implementation.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to check whether
# the number is positive, negative
# or equal to zero
  
def check(n):
      
    # if the number is positive
    if n > 0:
        print("Positive")
          
    # if the number is negative
    elif n < 0:
        print("Negative")
          
    # if the number is equal to
    # zero
    else:
        print("Equal to zero")
          
# Driver Code
check(5)
check(0)
check(-5)

chevron_right


Output:

Positive
Equal to zero
Negative
My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.