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
๐ŸŒ
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 โ€บ python โ€บ python-program-to-find-the-quotient-and-remainder-of-two-numbers
Python Program to find the Quotient and Remainder of two numbers - GeeksforGeeks
July 15, 2025 - The naive approach is to find the quotient using the double division (//) operator and remainder using the modulus (%) operator. ... # Python program to find the # quotient and remainder def find(n, m): # for quotient q = n//m print("Quotient: ...
Discussions

New modulo operator to get both quotient and remainder
Hello, I was doing some computation and sometimes we have to get quotient and remainder of a value, for instance quotient = value // divider remainder = value % divider So I was thinking maybe we could introduce a new operator to get both like quotient, remainder = value %% divider but I donโ€™t ... More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
September 25, 2023
modulo - Python quotient vs remainder - Stack Overflow
In Python, % works on floating-point numbers and can give a non-integer result. (JavaScript too.) 2010-01-28T02:25:27.407Z+00:00 ... This computes the (integer) remainder as explained by others. Then you divide by the denominator again, to produce the fractional part of the quotient. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Definitions - Print Quotient and Remainder - Python - Stack Overflow
I am asked to write a function called longDivision() that takes two integers as arguments and prints a well-labeled output of the quotient and remainder of the first argument divided by the second.... More on stackoverflow.com
๐ŸŒ stackoverflow.com
What's the difference between % (modulo) and // (floor division)
There's a function called divmod that does both, and if you use that a few times, you'll get a feel for the difference. For example, let's say you have a quantity of money, and you want to make change. cents = 93 quarters, cents = divmod(cents, 25) dimes, cents = divmod(cents, 10) nickels, cents = divmod(cents, 5) At each step, we take as many chunks as we can (that's the div), then we keep any leftovers (that's the mod) More on reddit.com
๐ŸŒ r/learnpython
9
0
September 15, 2024
๐ŸŒ
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 - # Define two numbers numerator ... print("Remainder:", remainder)Code language: Python (python) Run ... divmod() is a built-in Python function that returns both the quotient and remainder when dividing two numbers....
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
New modulo operator to get both quotient and remainder - Python Help - Discussions on Python.org
September 25, 2023 - Hello, I was doing some computation and sometimes we have to get quotient and remainder of a value, for instance quotient = value // divider remainder = value % divider So I was thinking maybe we could introduce a newโ€ฆ
๐ŸŒ
Quora
quora.com โ€บ How-do-you-find-the-quotient-and-remainder-in-Python
How to find the quotient and remainder in Python - Quora
For both positive and negative ... and remainder of integer division in Python, use the floor-division operator // for the quotient and the modulo operator % for the remainder....
Find elsewhere
๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ python-program-take-numbers-print-quotient-remainder
Python Program to Find Quotient and Remainder of Two Numbers - Sanfoundry
May 30, 2022 - 1. Take in the first and second number and store it in separate variables. 2. Then obtain the quotient using division and the remainder using modulus operator. 3. Exit. ... Here is the source code of the Python Program to read two numbers and ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_divmod.asp
Python divmod() Function
Python Examples Python Compiler ... Python Training ... The divmod() function returns a tuple containing the quotient and the remainder when argument1 (dividend) is divided by argument2 (divisor)....
๐ŸŒ
YouTube
youtube.com โ€บ watch
write a python program to find quotient and remainder - YouTube
Hello Programmers, Welcome to my Python Programming Tutorial Channel.In this video you will learn about how to write a python program to find quotient and re...
Published ย  September 8, 2024
๐ŸŒ
Django Central
djangocentral.com โ€บ python-program-to-compute-quotient-and-remainder-of-two-numbers
Python Program To Compute Quotient and Remainder Of Two Numbers
Enter the divisor 5 Enter the dividend 27 Quotient is 5 and Reminder is 2 ยท Here we are taking input from the user using the Python's built-in input() method then we are converting it to an integer using the int() method because input() returns the objects as a string object.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ built-in โ€บ divmod
Python divmod() - Quotient and Remainder | Vultr Docs
November 25, 2024 - The divmod() function in Python is a less commonly used but highly efficient utility that combines division and modulo operations into a single function call. This function takes two numbers as arguments and returns a tuple containing their ...
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ python โ€“ get quotient and remainder with divmod()
Python - Get Quotient and Remainder with divmod() - Be on the Right Side of Change
August 11, 2023 - In this case, the quotient is 20, and the remainder is 50. To summarize, the divmod() function in Python is an efficient way to obtain both the quotient and the remainder when dividing two non-complex numbers.
๐ŸŒ
Skytowner
skytowner.com โ€บ explore โ€บ getting_quotient_and_remainder_in_python
Getting quotient and remainder in Python
55_sJVEPqsBGOODtC2Zz2I We can use Python's divmod(~) built-in function to get the both the quotient and remainder. Alternatively, if we only want the quotient we can use // and if we only want the remainder we can use %.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ built-in โ€บ divmod
Python divmod() (with Examples)
# returns the quotient and remainder of 8/3 result = divmod(8, 3) print('Quotient and Remainder = ',result) # Output: Quotient and Remainder = (2, 2)
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 52758073 โ€บ definitions-print-quotient-and-remainder-python
Definitions - Print Quotient and Remainder - Python - Stack Overflow
first = float(input("Enter a number: ")) second = float(input("Enter a number: ")) def longDivision(num1, num2): # parameters can have different names than actual variables divideNum = num1 // num2 remainNum = num1 % num2 return divideNum, remainNum # return both quotient and remainder quo, rem = longDivision(first, second) # Pass the correct parameters print("The quotient is: ", quo) print("The remainder is: ", rem) ... longDivision("The quotient is: ") You are passing as string as a parameter while your function takes 2 float parameters ... Is it better to redirect users who attempt to perform actions they can't yet... 74 How do I get a decimal value when using the division operator in Python?
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 731780 โ€บ quotient-and-remainder-in-python-ex2063-while-2062
Quotient and remainder in python ex:20//6=3 while 20%6=2 | Sololearn: Learn to code for FREE!
20รท6 if want it to make a code for it it will be ,print(20//6) because the dividing mark in python is / or // the difference is that the first one will produce a float(decimal) and the second willnot produce a float or a decimal . but it doesn't change the result . back to 20//6=3 cause 3ร—6=18 but there's a remainder which we can get it by doing this 20%6=2 which is the remainder.
๐ŸŒ
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 - We care about the whole number result of the division (in this case 3), which is called the quotient. The amount left over after the division is called the remainder, which in this case is 1.
๐ŸŒ
Finxter
blog.finxter.com โ€บ 5-best-ways-to-calculate-quotient-and-remainder-in-python
5 Best Ways to Calculate Quotient and Remainder in Python โ€“ Be on the Right Side of Change
March 6, 2024 - Itโ€™s a neat and efficient way to perform both operations together. ... dividend = 10 divisor = 3 quotient, remainder = divmod(dividend, divisor) print("Quotient:", quotient) print("Remainder:", remainder)