Python program to check number is even or not

Solution with out using functions
Solution using functions without passing arguments
Solution using functions and by passing arguments


Solution : Without using function
Program/Source Code

For better understanding of this example, one should have the knowledge of the following Python programming topics:

Python if…else… Statement
Python if…else…if…else… Statement
Python if…elif…if…elif…else… Statement

Python program to check number is even or not

a=int(input("Enter any no "))
if(a%2==0):
    print("Number is even")
else:
    print("Number is not even")

Output:

Enter any no 58
Number is even
>>>
Enter any no 97
Number is not even
>>>



Solution : Using function Without Passing Arguments
Program/Source Code

#function definition
def even():
    a=int(input("Enter any no "))
    if(a%2==0):
        print("Number is even")
    else:
        print("Number is not even")


#function calling
even()

Output:

Enter any no 20
Number is even
>>>
Enter any no 21
Number is not even
>>>



Solution : Using function Passing Arguments
Program/Source Code

#function definition
def even(a):
    if(a%2==0):
        print("Number is even")
    else:
        print("Number is not even")


#function calling
a=int(input("Enter any no "))
even(a)

Output:

Enter any no 65
Number is not even
>>>
Enter any no 66
Number is even
>>>

You May Also Like:

Python Program to Check Number is +ve, -ve or zero
Python Program to check character is an alphabet or not
C Language Program to Print Fibonacci Series
Python Program for Prime Number upto a limit
Python Program to check character is an upper case alphabet or not
C Language Program for Factorial of a Number

Tutorials

Technical Questions and Important programs

Interview Questions

C Programming
C++ Programming
Basic Python Tutorial
Advanced Python Tutorial
C Language
C++ Programming
Python programming
C Important Programs
C Interview Questions
C++ Interview Questions
Python Interview Questions
HTML Interview Questions