Write a Python program that uses a lambda function to check whether a given number is even or odd. The function should return ‘Even’ for even numbers and ‘Odd’ for odd numbers.
Example 1:
Input: 4
Output: 'Even'
Example 2:
Input: 7
Output: 'Odd'
Use a lambda function to create an anonymous function that checks whether a number is even or odd.
# Define the lambda function
check_even_odd = lambda x: 'Even' if x % 2 == 0 else 'Odd'
# Test the function
print(check_even_odd(4)) # Output: 'Even'
print(check_even_odd(7)) # Output: 'Odd'
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.