Write a python program to check whether the given number is greater than 50 and also divisible by 2 using nested if else

In this source code example, we will write a python program to check whether the given number is greater than 50 and also divisible by 2 using nested if-else.

Program:

def checkNumber(num):
    if num > 50:
        if num % 2 == 0:
            return 'The given number ' + str(num) + ' is greater than 50 and divisible by 2'
        else:
            return 'The given number ' + str(num) + ' is greater than 50 but not divisible by 2'
    else:
        return 'The given number ' + str(num) + ' is lesser than 50'


print(checkNumber(60))
print(checkNumber(24))
print(checkNumber(55))

Output:

The given number 60 is greater than 50 and divisible by 2
The given number 24 is lesser than 50
The given number 55 is greater than 50 but not divisible by 2