From c78ff5bd4d8c69147b85a7162cc3be3a4fca708b Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 20 Aug 2019 14:19:55 +0300 Subject: [PATCH] Add is_divisible snippet --- snippets/is_divisible.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 snippets/is_divisible.md diff --git a/snippets/is_divisible.md b/snippets/is_divisible.md new file mode 100644 index 000000000..0f7f5d555 --- /dev/null +++ b/snippets/is_divisible.md @@ -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 +```