This is a Python Program to check whether a number is positive or negative.
The program takes a number and checks whether it is positive or negative.
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.
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")
1. User must first enter the value and store it in a variable.
2. Use an if statement to make a decision.
3. If the value of the number is greater than 0, “Number is positive” is printed.
4. If the value of the number if lesser than 0, ”Number is negative” is negative.
Case 1: Enter number: 45 Number is positive Case 2: Enter number: -30 Number is negative
Sanfoundry Global Education & Learning Series – Python Programs.
To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.
- Check Python Books
- Apply for Programming Internship
- Check Information Technology Books
- Apply for Python Internship
- Practice Programming MCQs