Define a function that can print the “It is an even number” if the number is even, otherwise print “It is an odd number”

Question:

Define a function that can accept an integer number as input and print the “It is an even number” if the number is even, otherwise print “It is an odd number”.

Hints:

  • Use the % operator to check if a number is even or odd.

Solution:

def checkValue(n):
	if n%2 == 0:
		print "It is an even number"
	else:
		print "It is an odd number"
		

checkValue(7)
Code language: Python (python)

Leave a Comment