- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
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 −
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")
It is a positive number
- 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 Articles
- How to check if a number is positive, negative or zero using Python?
- Java Program to Check Whether a Number is Positive or Negative
- Haskell Program to Check Whether a Number is Positive or Negative
- C++ 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++
- How to check whether a number is Positive or Negative in Golang?
- Java Menu Driven Program to Check Positive Negative or Odd Even Number
- What is zero if it is not a negative or positive number?
- 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
- Check if Array is Free From 0 and Negative Number in Java