# Python – Check if a Number is Positive or Negative

Contents

## Check if a Number is Positive or Negative

To check if a given number is positive or negative, we can use relational operators like greater-than, less-than and compare it with zero. If the given number is greater than zero, then it is a positive number, or if less than zero, then it is a negative number, or else, the given number is a zero.

### Example

In this example, we write a function to read a number from user, and check if the number is positive or negative.

Python Program

``````n = int(input('Enter a number : '))
if n > 0:
print(n, 'is a positive number.')
elif n < 0:
print(n, 'is a negative number.')
else:
print(n, 'is zero.')``````
Copy

Output #1

``````Enter a number : 4
4 is a positive number.``````

Output #2

``````Enter a number : -3
-3 is a negative number.``````

Output #3

``````Enter a number : 0
0 is zero.``````

### Summary

In this Python Examples tutorial, we learned how to check if given number is positive or negative using relational operators, and if-elif-else statement.

Code copied to clipboard successfully 👍