Checking divisibility
Write a Python function that takes two integers as input and returns “Divisible” if the first number is divisible by the second number, and “Not Divisible” otherwise. Treat num2 != 0 as a precondition; division by zero is outside this exercise’s input domain.
Complete Listing 1. Save the completed code as check_divisibility.py and run it to check the supplied assertions.
def check_divisibility(num1: int, num2: int) -> str:
raise NotImplementedError("Replace this line with your code.")
# Divides exactly
got = check_divisibility(12, 4)
assert got == "Divisible", f"12, 4: expected 'Divisible', got {got!r}"
# Leaves a remainder
got = check_divisibility(7, 3)
assert got == "Not Divisible", f"7, 3: expected 'Not Divisible', got {got!r}"
# Zero is divisible by anything
got = check_divisibility(0, 7)
assert got == "Divisible", f"0, 7: expected 'Divisible', got {got!r}"
# A negative first number still divides exactly
got = check_divisibility(-12, 4)
assert got == "Divisible", f"-12, 4: expected 'Divisible', got {got!r}"
# Your case: which pair is most likely to break it?
# got = check_divisibility(___, ___)
# 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.