The number is positive or negative and even or odd.

In this python if else program, we will check whether the number is positive or negative and even or odd.

Positive number:
A positive number is any number greater than zero. The positive number includes natural numbers.
Negative number:
A negative number is any number that is less than zero.
Odd number:
Odd numbers are those numbers that cannot be divided into two equal parts or cannot be divided by 2.
Even number:
even numbers are those numbers that can be divided into two equal parts or can be divided by 2.

Hint:
Use nested if-else statements.

Steps to solve the program
  1. Take a number as input through the user.
  2. Check whether the given number is positive or negative and even or odd with the help of the if-else statements
  3. Print the respective output.
				
					num = int(input("Enter a number: "))

if num>0:
    if num%2 == 0:
        print("The given number is positive and even")
    else:
        print("The given number is positive and odd")
else:
    if num%2 == 0:
        print("The given number is negative and even")
    else:
        print("The given number is negative and odd")
				
			

Output :

				
					Enter a number: 26
The given number is positive and even
				
			

Related Articles

check whether the given number is negative or not.

print the largest number from two numbers.

Leave a Comment