Prerequisite : Loops in Python
To check whether a number is positive, negative, odd, even or zero. This problem is solved using if…elif…else and nested if…else statement.
- A number is positive if it is greater than zero. We check this in the expression of if.
- If it is False, the number will either be zero or negative.
- This is also tested in subsequent expression.
- In case of odd and even A number is even if it is perfectly divisible by 2.
- When the number is divided by 2, we use the remainder operator % to compute the remainder.
- If the remainder is not zero, the number is odd.
Input : 10 Output : Positive number 10 is Even
Input : 0 Output : 0 is Even
Output: Positive number 10 is Even
Output: Positive number 20 is Even
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- C program to Check Whether a Number is Positive or Negative or Zero
- Python Program to Check Whether a Number is Positive or Negative or zero
- Python program to count positive and negative numbers in a list
- C program to count Positive and Negative numbers in an Array
- Python | Replace negative value with zero in numpy array
- Python | Counting sign change in list containing Positive and Negative Integers
- Python | Rearrange Positive and Negative Elements
- Python | Segregate Positive and Negative Integers from mixed string
- Find ratio of zeroes, positive numbers and negative numbers in the Array
- Highlight the negative values red and positive values black in Pandas Dataframe
- Lambda expression in Python to rearrange positive and negative numbers
- C program to check whether a given number is even or odd
- Minimum positive integer to divide a number such that the result is an odd
- Check if a Number is Odd or Even using Bitwise Operators
- Check if a HexaDecimal number is Even or Odd
- Check if an Octal number is Even or Odd
- Check whether count of odd and even factors of a number are equal
- Check whether given floating point number is even or odd
- Python Program to Print Largest Even and Largest Odd Number in a List
- Check if count of even divisors of N is equal to count of odd divisors
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.