Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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

  • Last Updated : 29 Aug, 2020

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


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Input: 5
Output: Positive

Input: -5
Output: Negative


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.


# 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:
    # if the number is negative
    elif n < 0:
    # if the number is equal to
    # zero
        print("Equal to zero")
# Driver Code


Equal to zero
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!