Q:

Create a function to check EVEN or ODD in Python

belongs to collection: Python basic programs

0

Create a function to check EVEN or ODD in Python

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Create a function to return the absolute the given... >>
<< Simple pattern printing programs in Python | Patte...