In this article, we have provided a Python program capable of telling whether that entered number is positive, negative, or Zero.
Prerequisites
- Python Input, Output
- Python if…else statement
- Python Data types
- Python Operators
Steps
- First, we ask the user to enter a number.
- Using the int() function, we will convert the entered string into an integer value.
- Using the if and elif statement, we check for conditions.
Python Program to Check if a Number is Positive, Negative or 0
num = int(input("Enter a number: "))
if num > 0:
print("You entered a Positive number")
elif num == 0:
print("You entered Zero")
else:
print("You entered a Negative number")
Output
Enter a number: -12 You entered a Negative number
People are also reading:
Leave a Comment on this Post