Write a Python Program to check Number is Positive or Negative with a practical example.
Python Program to check Number is Positive or Negative
This program allows the user to enter any numeric value. Next, using the Elif statement, this Python program verifies whether that number is positive, negative, or zero.
number = float(input(" Please Enter any Numeric Value : ")) if(number > 0): print("{0} is a Positive Number".format(number)) elif(number < 0): print("{0} is a Negative Number".format(number)) else: print("You have entered Zero")
The below Python statement asks the user to Enter any integer.
number = float(input(" Please Enter any Numeric Value : "))
In the next line, We declared the Else If statement
- The first Condition checks whether the given number is greater than 0. If it is true, then it is positive.
- Second condition: elif statement check whether a number is less than 0. If this is true, then the given value is negative.
- If both the above conditions fail, then it is 0.
output
Please Enter any Numeric Value : 12
12.0 is a Positive Number
This time, we are using Zero
Please Enter any Numeric Value : 0
You have entered Zero
Let me enter the negative value
