pythonbeginner10 minutes

Build a Function to Check Even or Odd Numbers

Create a simple Python function that takes an integer as input and returns whether the number is 'Even' or 'Odd'. This helps beginners practice conditionals and function definitions.

Challenge prompt

Write a function named check_even_odd that accepts one integer parameter and returns the string 'Even' if the number is even, or 'Odd' if the number is odd.

Guidance

  • Define a function using def and specify one parameter.
  • Use the modulo operator (%) to check if the number is divisible by 2.
  • Return 'Even' if the number modulo 2 equals zero; otherwise, return 'Odd'.

Hints

  • The modulo operator (%) gives the remainder when dividing two numbers.
  • If number % 2 == 0, the number is even; else it is odd.

Starter code

def check_even_odd(num):
    # Your code here
    pass

Expected output

check_even_odd(10) # Output: 'Even' check_even_odd(7) # Output: 'Odd'

Core concepts

functionsconditionalsmodulo operator

Challenge a Friend

Send this duel to someone else and see if they can solve it.