TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Python divmod() function with Examples

Python divmod() function with Examples on append(), clear(), extend(), insert(), pop(), remove(), index(), count(), pop(), reverse(), sort(), copy(), all(), bool(), enumerate(), iter(), map(), min(), max(), sum() etc.

<< Back to PYTHON

Python divmod() Function

Python 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.

Signature

divmod (number1, number2)

Parameters

number1: A numeric value, it is required.

number2: A numeric value, it is required.

Return

It returns a tuple.

Let's see some examples of divmod() function to understand it's functionality.

Python divmod() Function Example 1

Let'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 2

It 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 3

Here, 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




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf