In this tutorial we will learn about the python divmod() method and how to use it.
What is Python divmod() Method?
The divmod() method takes two numbers and returns a pair of numbers inside a tuple consisting of their quotient and remainder.
The syntax of divmod() is:
Python divmod() Method Parameters
divmod() takes two parameters:
x – a non-complex number that can be referred to as a numerator.
y – a non-complex number that can be referred to as denominator
Let see an example of divmod() method.
Example: How divmod() works in python?
The output will be as follows.
Rules of divmod()
(q, r) – a pair of numbers will be a tuple consisting of quotient q and a remainder r.
If x and y are integers, the return values from divmod() is same as (a //b , x % y).