divmod(): quotient and remainder of a division in Python

The divmod() function takes two arguments, the first is the divident, and the second is the divisor.

The function returns a tuple containing the quotient and the remainder of the division.

In this example, 13 is the divident a 4 is the divisor.

The tuple results in a quotient of 3 and a remainder of 1.

result = divmod(13,4)
print(result)
(3, 1)

You can also assign the quotient and the remainder to separate variables to increase the readability of your code.

quotient, remainder = divmod(13,4)
print(quotient)
print(remainder)
3
1