Python divmod() Function
The Python divmod() function combines the results of division and remainder operations, returning a tuple (a // b, a % b) containing the quotient and the remainder.
Before Python 2.3, complex numbers were not allowed.
Function syntax
divmod(a, b)
Parameter Description:
- a: a number
- b: a number
Example
divmod
(
7
,
2
)
(
3
,
1
)
divmod
(
8
,
2
)
(
4
,
0
)
divmod
(
1
2j
,
1
0.5j
)
(
(
1
0j
)
,
1.5j
)
Python built-in function