# divmod() function with example in Python

Python divmod() function: Here, we are going to learn about the divmod() function in Python with example.
Submitted by IncludeHelp, on April 04, 2019

## Python divmod() function

divmod() function is a library function, it is used to get the quotient and remainder of given values (dividend and divisor), it accepts two arguments 1) dividend and 2) divisor and returns a tuple that contains quotient and remainder.

Syntax:

```    divmod(dividend, divisor)
```

Parameter(s):

• dividend – a number to be divided.
• divisor – a number to be divided with.

Return value: tuple – it returns a tuple containing quotient and remainder.

Example:

```    Input:
a = 10  #dividend
b = 3   #divisor

# finding quotient and remainder
result = divmod(a,b)
print("result = ", result)

Output:
result =  (3, 1)
```

Python code to find quotient and remainder of two numbers

```# python code to demonstrate example of
# divmod() number

a = 10  #dividend
b = 3   #divisor

print("return type of divmod() function: ", type(divmod(a,b)))

# finding quotient and remainder
result = divmod(a,b)
print("result = ", result)

# float values
a = 10.23  #dividend
b = 3.12   #divisor

# finding quotient and remainder
result = divmod(a,b)
print("result = ", result)
```

Output

```return type of divmod() function:  <class 'tuple'>
result =  (3, 1)
result =  (3.0, 0.8700000000000001)
```

Preparation