Home » Python Check Number Positive Negative or Zero

Python Check Number Positive Negative or Zero

by Online Tutorials Library

Python Program to check if a Number is Positive, Negative or Zero

Here, we will learn to write a Python program through which we can check if the given number is positive, zero, or negative.

Positive Numbers: A number is said to be positive if the number has a value greater than 0, like 1, 2, 3, 5, 7, 9, 11, 13, etc. All the natural numbers are positive numbers.

Negative Numbers: If a given number has a value less than 0 like -1, -2, -3, -5, -7, -9, -11, -13, etc., then we can say that the given number is a negative number. Only rational and integer type numbers can have negative values or numbers.

Python Condition And Loops1

Let us look at the following example to understand the implementation

Example:

Output:

Enter a number as input value: -6  Number given by you is Negative  

Explanation:

We have used a nested if else condition in the program to check the number. When the user gives an input number, the program will first check if the value of the number is greater than 0 (if yes, it will print positive and the program ends), otherwise it will check if the value is less than 0 and it last it will print that number is 0.


You may also like