Create a function to check EVEN or ODD in Python

Here, we are going to learn to create a function to check whether a given number is an EVEN or ODD number in Python programming language. By IncludeHelp Last updated : January 05, 2024

Problem statement

In the below program – we are creating a function named "CheckEvenOdd()", it accepts a number and returns "EVEN" if the number is EVEN or returns "ODD" if the number is ODD.

Python program to create a function to check EVEN or ODD

# Python function to check EVEN or ODD
def CheckEvenOdd(num): 
  if (num % 2 == 0): 
    print(num," is EVEN")
  else: 
    print(num," is ODD")
  
# main code
CheckEvenOdd(11) 
CheckEvenOdd(22) 
CheckEvenOdd(33)
CheckEvenOdd(44)

Output

The output of the above program is:

11  is ODD
22  is EVEN
33  is ODD
44  is EVEN

Python Basic Programs »

To understand the above program, you should have the basic knowledge of the following Python topics:

Related Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.