Write a Python program to find postive or negative number

Positive Numbers: Any number above zero is known as a positive number. Positive numbers are written without any sign or a '+' sign in front of them and they are counted up from zero, i.e. 1, + 2, 3, +4 etc.

Negative Numbers:  Any number below zero is known as a negative number. Negative numbers are always written with a '−' sign in front of them and they are counted down from zero, i.e. -1, -2, -3, -4 etc.

Always look at the sign in front of a number to check if it is positive or negative. Zero, 0, is neither positive nor negative.

example 1:-
num = float(input("Input a number: "))
if num > 0:
   print("It is positive number")
elif num == 0:
   print("It is Zero")
else:
   print("It is a negative number")
output 1:-

Input a number: 10
It is positive number

output 2:-

Input a number: -12
It is a negative number

example 2:-

num = float(input("Enter a number: "))
if num >= 0:
   if num == 0:
       print("Zero")
   else:
       print("Positive number")
else:
   print("Negative number")
output:-
Enter a number: 10
Positive number

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post