you are looking for the modulo operator:

a % b

for example:

>>> 26 % 7
5

Of course, maybe they wanted you to implement it yourself, which wouldn't be too difficult either.

Answer from Uku Loskit on Stack Overflow
๐ŸŒ
Runestone Academy
runestone.academy โ€บ ns โ€บ books โ€บ published โ€บ thinkcspy โ€บ SimplePythonData โ€บ OperatorsandOperands.html
2.7. Operators and Operands โ€” How to Think like a Computer Scientist: Interactive Edition
If youโ€™re working with expressions where you need floating point values, use the division operator /. If you want an integer result, use //. The modulus operator, sometimes also called the remainder operator or integer remainder operator works on integers (and integer expressions) and yields ...
Discussions

How to make Python correctly divide?
How to make Python correctly divide ??? It issues -29 // 5 = - 6 ??? and it should be - 5 !!! It issues -29 % 5 = 1 ??? and it should be - 4 !!! More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
September 9, 2021
Why Python's Integer Division Floors
I point I found rather funny... In mathematical number theory, mathematicians always prefer the latter choice (floor). isn't right (it even says so in the linked Wikipedia article). Number Theorists tend use the method where a mod b gives the least nonnegative representative. More on reddit.com
๐ŸŒ r/ProgrammingLanguages
11
13
February 16, 2024
Is there any reason to have integer division?
Integer division is generally a native operation on modern CPUs. To the extent that a programming language is meant to allow programmers to tell a computer what to do, this seems self-defeating. Casting to floats then dividing then casting back may be less efficient than integer divsion. The two operations are not numerically equivalent as information is lost when casting a N-bit int to an N-bit float as the significand will necessarily be smaller than the int to make room for the exponent and sign bit fields. More on reddit.com
๐ŸŒ r/ProgrammingLanguages
96
21
August 6, 2024
Please help me with this code.
Well, first of all, you need to perform the test to see if the user has input 0 for the divisor (the number to divide by) before you attempt the division. Otherwise, you'll hit an error. Fortunately, you can do this by simply rearranging your code. Also, you're defining your dividend and divisor within your function; you don't need to send them as parameters to the function. This, for example, ought to work (note the lack of a def header): num_1 = int(input("Please enter the number to divide by: ")) num_2 = int(input("Please enter the number to divide: ")) if num_1 == 0: print('ERROR! Division by zero is undefined.') elif num_2 == 0: print('Zero divided by anything is zero.') else: remainder = num_2 % num_1 if remainder: print(f"{num_2} is not divisible by {num_1}, there is a remainder of {remainder}.") else: print(f"{num_2} is divisible by {num_1}") NOTE: Edited to address spelling error. More on reddit.com
๐ŸŒ r/learnpython
19
7
June 22, 2023
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Integer division - Python Help - Discussions on Python.org
January 25, 2023 - What is the result of this code: print(6 // 0.4) I thought the answer is 15.0 but I am getting 14.0. Any explanation for this answer I will appreciate.
๐ŸŒ
Hyperskill
hyperskill.org โ€บ university โ€บ python โ€บ integer-division-operator-in-python
Integer Division Operator in Python
December 25, 2025 - In Python, integer division, also referred to as floor division, involves discarding the remainder and returning the whole number part of the quotient. To perform division, in Python, you use two slashes (//). For instance, if you wish to divide two numbers and get the part of the outcome, ...
๐ŸŒ
OpenStax
openstax.org โ€บ books โ€บ introduction-python-programming โ€บ pages โ€บ 2-5-dividing-integers
2.5 Dividing integers - Introduction to Python Programming | OpenStax
March 13, 2024 - Ex: 7 // 4 is 1 because 4 goes into 7 one time, remainder 3. The modulo operator (%) computes the remainder. Ex: 7 % 4 is 3. Note: The % operator is traditionally pronounced "mod" (short for "modulo"). Ex: When reading 7 % 4 out loud, a programmer ...
๐ŸŒ
The Teclado Blog
blog.teclado.com โ€บ pythons-modulo-operator-and-floor-division
Python's modulo operator and floor division - The Teclado Blog
October 26, 2022 - The amount left over after the division is called the remainder, which in this case is 1. To give you another example, 11 / 3 gives us a quotient of 3 and a remainder of 2. In Python, the modulo operator simply yields the remainder:
๐ŸŒ
Enterprise DNA
blog.enterprisedna.co โ€บ how-to-divide-in-python-easy-examples
How to Divide in Python: Easy Examples โ€“ Master Data Skills + AI
To perform division in Python, you can either use the single forward slash(/) for float division, or the double forward slash for integer division. You can also use NumPyโ€™s library built-in function np.divide when dividing one array by the other. Furthermore, the % operator returns the remainder ...
Find elsewhere
๐ŸŒ
Real Python
realpython.com โ€บ python-modulo-operator
Python Modulo Operator (%): How to Use Mod in Python โ€“ Real Python
April 1, 2023 - The modulo operator, when used with two positive integers, will return the remainder of standard Euclidean division: ... Be careful! Just like with the division operator (/), Python will return a ZeroDivisionError if you try to use the modulo ...
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Get Quotient and Remainder in Python: divmod() | note.nkmk.me
May 8, 2023 - In Python, you can easily compute the quotient using the // operator and the remainder using the % operator. If you need both the quotient and remainder, the built-in function divmod() is a convenient ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ division-operators-in-python
Division Operators in Python - GeeksforGeeks
There are two types of division operators: Float divisionInteger division( Floor division)When an in ... Modulo operator (%) in Python gives the remainder when one number is divided by another. Python allows both integers and floats as operands, ...
Published ย  April 25, 2025
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
How to make Python correctly divide? - Python Help - Discussions on Python.org
September 9, 2021 - How to make Python correctly divide ??? It issues -29 // 5 = - 6 ??? and it should be - 5 !!! It issues -29 % 5 = 1 ??? and it should be - 4 !!!
๐ŸŒ
Quora
quora.com โ€บ How-do-you-find-the-division-and-remainder-in-Python
How to find the division and remainder in Python - Quora
Answer (1 of 3): The following are the operators: 1. โ€˜/โ€™ : normal division : 2. 1. this is used to divide a number by another another number and the result is obtained in floating format 2. syntax : x/y : returns the value of x divided by y in a decimal value of 15 digits after decimal 3. โ€˜//โ€™...
๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ programs and examples โ€บ python programs to find quotient and remainder
Python Find Quotient and Remainder [3 Ways] โ€“ PYnative
March 27, 2025 - In Python, you can find the quotient and remainder using the Quotient Divison (//) and Modulo (%) operator, respectively. Quotient Divison (//): This operator in Python is also called the Floor Division or Integer Division operator. It divides two numbers and returns the integer division, i.e., ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ the-python-modulo-operator-what-does-the-symbol-mean-in-python-solved
The Python Modulo Operator - What Does the % Symbol Mean in Python? (Solved)
December 29, 2019 - The % symbol in Python is called the Modulo Operator. It returns the remainder of dividing the left hand operand by right hand operand. It's used to get the remainder of a division problem.
๐ŸŒ
LearnDataSci
learndatasci.com โ€บ solutions โ€บ python-double-slash-operator-floor-division
Python Double Slash (//) Operator: Floor Division โ€“ LearnDataSci
Looking at the result of regular division when both numbers are positive, $\frac{15}{4}=3.75$, floor division returns $3$, since it's the largest integer less than or equal to $3.75$. When one of the operands is negative, the result of normal division is negative ($-3.75$), so the largest integer ...
๐ŸŒ
Reddit
reddit.com โ€บ r/programminglanguages โ€บ why python's integer division floors
r/ProgrammingLanguages on Reddit: Why Python's Integer Division Floors
February 16, 2024 - Floored division produces remainders whose sign is the same as the divisor. The Wikipedia article (cited in the blog post too) has some nice graphics to show it. https://en.m.wikipedia.org/wiki/Modulo ... BTW, the >> operator of a signed integer by an integer n is equivalent to flooring division by 2**n . That is because the shifted-out bits are just discarded, without doing any rounding. This is not just to Python...
๐ŸŒ
Career Karma
careerkarma.com โ€บ blog โ€บ python โ€บ how to use the python modulo operator
How to Use the Python Modulo Operator | Career Karma
December 1, 2023 - The modulo operator calculates the remainder of a division sum. It is commonly used to check whether a number is odd or even. The Python modulo operator is represented using the percent sign (%).
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ modulo-operator-python
Modulo Operator in Python: Understanding Key Concepts | DataCamp
March 12, 2025 - If you're new to Python, consider taking our Introduction to Python course. The modulo operator (%) computes the remainder of the division between two numbers. Given two numbers a (dividend) and b (divisor), the modulo operation returns the remainder when a is divided by b. Modulo has its roots ...
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ integer-division
What does // mean in Python? - Python Morsels
October 17, 2022 - For most uses of division in Python, ... in rare moments when you want floor division (a.k.a. integer division) you'll want the // operator....