Member-only story
Finding the Remainder in Python
Introduction
Today, we’ll be exploring a Python programming problem called “Return the Remainder from Two Numbers.” This problem is an excellent opportunity to practice your skills and learn some fundamental concepts in Python, such as the modulo operator.
By the end of this article, you’ll have a better understanding of how to write a simple function to find the remainder of a division operation.
Problem Statement
The problem we’re trying to solve is as follows:
There is a single operator in Python, capable of providing the remainder of a division operation. Two numbers are passed as parameters. The first parameter divided by the second parameter will have a remainder, possibly zero. Return that value.
Here are some examples of how the function should work:
- remainder(1, 3) ➞ 1
- remainder(3, 4) ➞ 3
- remainder5, 5) ➞ 0
- remainder(7, 2) ➞ 1
Note: The tests only use positive integers.