![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements