Challenge 1: Check If Even or Odd
This lesson will check your knowledge of if expression.
We'll cover the following
Problem Statement
Write a code which will check whether _a
given integer number is even
or odd
. If the number is even print “Number a is even” and if it’s an odd print “Number a is odd”.
Input
integer
Output
Number a is even or Number a is odd
Where a is the number given as input.
Sample Input
3
Sample Output
Number 3 is odd
Coding Exercise
Write your code below. It is recommended that you try solving the exercise yourself before viewing the solution.
Note: There is a
test
function given in the code for testing purposes. Do not modify it. Solve the challenge below:
Important Note: Assume that the number to be checked is stored in the variable
_a
in the following code.
Good luck!🤞
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy