Simple if statement
Write a Python function that takes an integer as input and returns “Even” if the number is even and “Odd” if it’s odd.
Complete Listing 1. Save the completed code as check_even_odd.py and run it to check the supplied assertions.
def check_even_odd(num: int) -> str:
raise NotImplementedError("Replace this line with your code.")
# An even number
got = check_even_odd(4)
assert got == "Even", f"4: expected 'Even', got {got!r}"
# An odd number
got = check_even_odd(7)
assert got == "Odd", f"7: expected 'Odd', got {got!r}"
# Zero: even, and easy to get wrong
got = check_even_odd(0)
assert got == "Even", f"0: expected 'Even', got {got!r}"
# A negative odd number, where the remainder can surprise you
got = check_even_odd(-7)
assert got == "Odd", f"-7: expected 'Odd', got {got!r}"
# Your case: which number is most likely to break it?
# got = check_even_odd(___)
# assert got == "___", f"___: expected '___', got {got!r}"
TipHint
assert conditionchecks a Boolean condition. A true condition produces no output; a false condition raisesAssertionError. For example,assert 2 + 3 == 5passes.a % breturns the remainder after division by nonzerob. For example,7 % 3is1, and12 % 4is0.