Python divmod() Function
The Python divmod() function combines the division and remainder operations, returning a tuple containing the quotient and remainder (a // b, a % b).
Before Python version 2.3, handling complex numbers was not allowed.
Function Syntax
divmod(a, b)
Parameter Description:
- a: Number
- b: Number
Examples
>>>divmod(7, 2)
(3, 1)
>>> divmod(8, 2)
(4, 0)
>>> divmod(1+2j,1+0.5j)
((1+0j), 1.5j)
Python Built-in Functions