Checks if the first numeric argument is divisible by the second one.
- Use the modulo operator (
%
) to check if the remainder is equal to0
.
代码实现
def is_divisible(dividend, divisor):
return dividend % divisor == 0
使用样例
is_divisible(6, 3) # True