×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

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:

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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