C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Python divmod() FunctionPython divmod() function is used to get remainder and quotient of two numbers. This function takes two numeric arguments and returns a tuple. Both arguments are required and numeric. This function has the following syntax. Signaturedivmod (number1, number2) Parametersnumber1: A numeric value, it is required. number2: A numeric value, it is required. ReturnIt returns a tuple. Let's see some examples of divmod() function to understand it's functionality. Python divmod() Function Example 1Let's see a simple example to call divmod() function. # Python divmod() function example # Calling function result = divmod(10,2) # Displaying result print(result) Output: (5, 0) Python divmod() Function Example 2It also allows passing float values as an argument. See an example below. # Python divmod() function example # Calling function result = divmod(5.5,2.5) # Displaying result print(result) Output: (2.0, 0.5) Python divmod() Function Example 3Here, we are passing the first argument as integer and second as a float value. # Python divmod() function example # Calling function result = divmod(5.5,2) # Displaying result print(result) Output: (2.0, 1.5)
Next TopicPython Functions
|