In this article we have provided a Python program that is capable of telling that entered number is positive, negative or Zero.
Prerequisite topics to create this program.
- Python Input, Output
- Python if…else statement
- Python Data types
- Python Operators
- 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")
Enter a number: -12 You entered a Negative number
People are also reading: