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.
Submitted by IncludeHelp, on March 02, 2020

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 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

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

Python Basic Programs »



Related Programs

ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.