Python Program to Check Whether a Number is Positive or Negative
Python Program to Check Whether a Number is Positive or Negative
This is a Python Program to check whether a number is positive or negative.
Problem Description
The program takes a number and checks whether it is positive or negative.
Problem Solution
1. Take the value of the integer and store in a variable.
2. Use an if statement to determine whether the number is positive or negative.
3. Exit.
Program/Source Code
Here is the source code of the Python Program to check whether a number is positive or negative. The program output is also shown below.
n=int(input("Enter number: "))
if(n>0):
print("Number is positive")
else:
print("Number is negative")
Runtime Test Cases
Case 1:
Enter number: 45
Number is positive
Case 2:
Enter number: -30
Number is negative