In this example, you will learn to check whether the user entered Number is Positive, Negative or 0
This Program to find Number is Positive, Negative or 0 can be solved using if…elif…else and nested if…else statement.
To understand this example, you should have knowledge of following Python programming topics:
- Python if…else Statement
- Python Input, Output and Import
Program to Check if a Number is Positive, Negative or 0 using if…elif…else
num = float(input("Enter a number: "))
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
Output
Enter a number: 2
Positive number

Here, we have used the if...elif...else
statement. We can do the same thing using nested if
statements as follows.
Program to Check if a Number is Positive, Negative or 0 using Using Nested if
num = float(input("Enter a number: "))
if num >= 0:
if num == 0:
print("Zero")
else:
print("Positive number")
else:
print("Negative number")
Output
Enter a number: 2
Positive number

If you notice the output of both the Programs is the same, so we can use any method to Check if a Number is Positive, Negative or zero.
Ask your questions and clarify your doubts on the Program to Check if a Number is Positive, Negative or zero by commenting. Python Documentation
Related Program
- Python Program to Find LCM
- Python Program to Find HCF or GCD
- Python Program To Display Powers of 2 Using Anonymous Function
- Python Program to Display Calendar
- Python Program to find the Square Roots
- Python Program to Shuffle Deck of Cards
- Python program convert decimal number to binary number using recursion
- Python Program to Find Factorial of a Number Using Recursion
- Python Program to Check if a Number is Positive, Negative or 0
- Python Program to Display Fibonacci Sequence Using Recursion