Add is_divisible snippet

This commit is contained in:
Angelos Chalaris
2019-08-20 14:19:55 +03:00
parent a3d9509dd8
commit c78ff5bd4d

17
snippets/is_divisible.md Normal file
View File

@ -0,0 +1,17 @@
---
title: is_divisible
tags: math,beginner
---
Checks if the first numeric argument is divisible by the second one.
Use the modulo operator (`%`) to check if the remainder is equal to `0`.
```py
def is_divisible(dividend, divisor):
return dividend % divisor == 0
```
```py
is_divisible(6, 3) # True
```