Checking age eligibility
Assume the age is a nonnegative integer.
Write a Python function that takes an age as input and returns "Eligible" if the age is 18 or older, and "Not Eligible" otherwise.
Complete Listing 1. Save the completed code as check_age_eligibility.py and run it to check the supplied assertions.
def check_age_eligibility(age: int) -> str:
raise NotImplementedError("Replace this line with your code.")
# Below the threshold
got = check_age_eligibility(17)
assert got == "Not Eligible", f"age 17: expected 'Not Eligible', got {got!r}"
# At the threshold: the case most likely to be wrong
got = check_age_eligibility(18)
assert got == "Eligible", f"age 18: expected 'Eligible', got {got!r}"
# Above the threshold
got = check_age_eligibility(19)
assert got == "Eligible", f"age 19: expected 'Eligible', got {got!r}"
# Your case: which age is most likely to break it?
# got = check_age_eligibility(___)
# assert got == "___", f"age ___: 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.