

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to Check if a Number is Positive, Negative or 0
When it is required to check if a number is positive, negative or 0, a simple ‘if’ condition can be used.
Below is a demonstration for the same −
Example
my_num = 58 if my_num >= 0: if my_num == 0: print("The number is equal to zero") else: print("It is a positive number") else: print("It is a negative number")
Output
It is a positive number
Explanation
- A number is defined.
- It is checked to see if it is 0, otherwise if it is greater than 0, it is shown as positive number.
- If both these conditions don’t hold good, it is determined to be a negative number.
- It is then displayed as output on the console.
- Related Questions & Answers
- How to check if a number is positive, negative or zero using Python?
- Java Program to Check Whether a Number is Positive or Negative
- C program to Check Whether a Number is Positive or Negative or Zero?
- Program to check if a number is Positive, Negative, Odd, Even, Zero?
- C# Program to check if a number is Positive, Negative, Odd, Even, Zero
- Java program to find if the given number is positive or negative
- Check if a number is positive, negative or zero using bit operators in C++
- Python program to check if a number is Prime or not
- Check whether product of integers from a to b is positive, negative or zero in Python
- Python Program to Check if a Number is a Perfect Number
- Python Program to Check if a Number is a Strong Number
- Java Program to convert positive int to negative and negative to positive
- Sum a negative number (negative and positive digits) - JavaScript
- C# Program to check if a number is prime or not
- PHP program to check if a number is prime or not
Advertisements