PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
    • Python Exercises
    • C Programming Exercises
    • C++ Exercises
  • Quizzes
  • Code Editor
    • Online Python Code Editor
    • Online C Compiler
    • Online C++ Compiler
Home » Python » Programs and Examples » Python Programs to Find Quotient and Remainder

Python Programs to Find Quotient and Remainder

Updated on: March 27, 2025 | Leave a Comment

When a number (dividend) is divided by another number (divisor), the result consists of two parts:

  1. Quotient → The whole number result of the division.
  2. Remainder → The leftover part that cannot be evenly divided.

For 10 ÷ 3:

  • Quotient = 10 // 3 = 3
  • Remainder = 10 % 3 = 1

In Python, you can find the quotient and remainder using multiple approaches. Here are all the standard ways with examples.

Table of contents

  • 1. Using Quotient Divison ( // ) and Modulo ( % ) operators
  • 2. Using divmod() function
  • 3. Using mathematical formula

1. Using Quotient Divison (//) and Modulo (%) operators

In Python, you can find the quotient and remainder using the Quotient Divison (//) and Modulo (%) operator, respectively.

Quotient Divison (//): This operator in Python is also called the Floor Division or Integer Division operator. It divides two numbers and returns the integer division, i.e., quotient.
For Example, 13 // 5 = 2 because 13 ÷ 5 equals 2.

Modulo Operator (%): This operator returns the remainder after dividing the first number by the second.
For Example, 13 % 5 = 3 because when 13 is divided by 5, the remainder left is 3.

Code Example

# Define two numbers
numerator = 13
denominator = 5

# Calculate quotient
quotient = numerator // denominator

# Calculate remainder
remainder = numerator % denominator

print("Quotient:", quotient)
print("Remainder:", remainder)Code language: Python (python)

Output:

Quotient: 2
Remainder: 3Code language: Python (python)

2. Using divmod() function

divmod() is a built-in Python function that returns both the quotient and remainder when dividing two numbers. The divmod() function takes two numbers as arguments and returns a tuple containing both the quotient and remainder.

Syntax:- divmod(a, b)

  • a → Dividend (the number to be divided).
  • b → Divisor (the number that divides a).
  • Returns a tuple: (quotient, remainder)

For Example – divmod(13, 5) returns (2, 3), where 2 is the quotient, and 3 is the remainder.

Code Example

# Define two numbers
numerator = 13
denominator = 5

quotient, remainder = divmod(numerator, denominator)

# Output results
print("Quotient:", quotient)
print("Remainder:", remainder)

# Output:
# Quotient: 2
# Remainder: 3Code language: Python (python)

3. Using mathematical formula

The mathematical formula to calculate the quotient is:
Quotient = Numerator ÷ Denominator

The mathematical formula to calculate the remainder:
Remainder = Numerator − ( Quotient × Denominator )

For Example, 13 ÷ 5:
Here, numerator = 13 and denominator = 5
Quotient = Numerator // Denominator = 13 // 5 = 2
Remainder = Numerator − ( Quotient * Denominator ) = 13 - ( 2 * 5 ) = 3

Code Example

import math

# Define two numbers
numerator = 13
denominator = 5

# Quotient using floor
quotient = math.floor(numerator / denominator)

# Remainder using formula
remainder = numerator - (quotient * denominator)

print("Quotient:", quotient)
print("Remainder:", remainder)

# Output:
# Quotient: 2
# Remainder: 3Code language: Python (python)

Filed Under: Programs and Examples, Python, Python Basics

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Programs and Examples Python Python Basics

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Leave a Reply Cancel reply

your email address will NOT be published. all comments are moderated according to our comment policy.

Use <pre> tag for posting code. E.g. <pre> Your entire code </pre>

In: Programs and Examples Python Python Basics
TweetF  sharein  shareP  Pin

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

  Python Tutorials

  • Get Started with Python
  • Python Statements
  • Python Comments
  • Python Keywords
  • Python Variables
  • Python Operators
  • Python Data Types
  • Python Casting
  • Python Control Flow statements
  • Python For Loop
  • Python While Loop
  • Python Break and Continue
  • Python Nested Loops
  • Python Input and Output
  • Python range function
  • Check user input is String or Number
  • Accept List as a input from user
  • Python Numbers
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python Functions
  • Python Modules
  • Python isinstance()
  • Python OOP
  • Python Inheritance
  • Python Exceptions
  • Python Exercise for Beginners
  • Python Quiz for Beginners

All Python Topics

  • Python Basics
  • Python Exercises
  • Python Quizzes
  • Python File Handling
  • Python Date and Time
  • Python OOP
  • Python Random
  • Python Regex
  • Python Pandas
  • Python Databases
  • Python MySQL
  • Python PostgreSQL
  • Python SQLite
  • Python JSON

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2026 pynative.com