Python Program to Check if a Number is Positive, Negative or 0

By | September 28, 2021
Python Program to Check if a Number is Positive, Negative or 0

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

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: 

Author: Vinay

I am a Full Stack Developer with a Bachelor's Degree in Computer Science, who also loves to write technical articles that can help fellow developers.

Leave a Reply

Your email address will not be published.