This divmod()
function returns a quotient and remainder after a division of two numbers.
divmod(dividend, divisor)
Here,
Note: With mixed operand types, the rules for binary arithmetic operators apply. For plain and long integers, the result is the same as (a // b, a % b). For floating-point numbers, the result is (q, a % b), where q is math.floor(a/b)
.
>>> divmod(10, 3)
(3, 1)
>>> divmod(10.5, 3)
(3.0, 1.5)
>>> divmod(10.5, 3.1)
(3.0, 1.1999999999999997)
>>> divmod(10.5, 3.5)
(3.0, 0.0)