A Program to Check a Number is Positive or Negative

In this example, we are giving a program to check a number given by user is positive, negative or zero.


Program to check a number is positive, negative or zero:

  1. # Check a number is positive, negative or zero
  2. num = float(input('Enter a number: '))
  3. if num > 0:
  4. print("Positive number")
  5. elif num == 0:
  6. print("Zero")
  7. else:
  8. print("Negative number")

Output:

Enter a number: 7
Positive number