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

When it is required to check if a number is positive, negative or 0, a simple ‘if’ condition can be used.

Below is a demonstration for the same −


 Live Demo

my_num = 58
if my_num >= 0:
   if my_num == 0:
      print("The number is equal to zero")
      print("It is a positive number")
   print("It is a negative number")


It is a positive number


  • A number is defined.
  • It is checked to see if it is 0, otherwise if it is greater than 0, it is shown as positive number.
  • If both these conditions don’t hold good, it is determined to be a negative number.
  • It is then displayed as output on the console.