Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python divmod() Function

Python divmod() Function

Python built-in function Python built-in 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:

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 Python built-in function