
- 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
How to check if a number is positive, negative or zero using Python?
Using if-elif-else
num = float(input("Enter a number: ")) if num > 0: print("Positive ") elif num == 0: print("Zero") else: print("Negative ")
using nested if
num = float(input("Enter a number: ")) if num >= 0: if num == 0: print("Zero") else: print("Positive") else: print("Negative")
- Related Articles
- Check if a number is positive, negative or zero using bit operators in C++
- C program to Check Whether a Number is Positive or Negative or Zero?
- Python Program to Check if a Number is Positive, Negative or 0
- 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
- What is zero if it is not a negative or positive number?
- Check whether product of integers from a to b is positive, negative or zero in Python
- How to check whether a number is Positive or Negative in Golang?
- 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
- Why is there no zero positive and negative number?
- How to Check if a Number is Odd or Even using Python?
- Java program to find if the given number is positive or negative
- Java Menu Driven Program to Check Positive Negative or Odd Even Number

Advertisements