
- 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
Program to check if a number is Positive, Negative, Odd, Even, Zero?
Number is given, we have to check that the number is even or odd and positive or negative.
Algorithm
Step 1: input number Step 2: check number is greater than equal to 0 or not. If true then positive otherwise negative and if it 0 then number is 0. Step 3: if number is divisible by 2 then it’s even otherwise its odd.
Example code
# Python program check if a number is Positive, Negative, Odd, Even, Zero n=int(input("Enter Number ::>")) if n >= 0: if n == 0: print("The Number Is Zero") else: print("This Is Positive Number") else: print("This Is Negative Number") # checking for odd and even if (n % 2) == 0: print("{0} is Even".format(n)) else: print("{0} is Odd".format(n))
Output
Enter Number ::>20 This Is Positive Number 20 is Even
- Related Articles
- C# Program to check if a number is Positive, Negative, Odd, Even, Zero
- Java Menu Driven Program to Check Positive Negative or Odd Even Number
- How to check if a number is positive, negative or zero using Python?
- C program to Check Whether a Number is Positive or Negative or Zero?
- Check if a number is positive, negative or zero using bit operators in C++
- Python Program to Check if a Number is Positive, Negative or 0
- What is zero if it is not a negative or positive number?
- Java Program to Check Whether a Number is Positive or Negative
- C++ Program to Check Whether a Number is Positive or Negative
- Haskell Program to Check Whether a Number is Positive or Negative
- Java Program to Check Whether a Number is Even or Odd
- Haskell Program to Check Whether a Number is Even or Odd
- C++ Program to Check Whether Number is Even or Odd
- How to Check if a Number is Odd or Even using Python?
- PHP program to check if the total number of divisors of a number is even or odd

Advertisements