Python Program To Compute Quotient and Remainder Of Two Numbers

2 min read

In Division The number which we divide is called the dividend. The number by which we divide is called the divisor. The result obtained is called the quotient. The number left over is called the remainder.

Remainder-and-Quotient

Problem Definition

Create a Python program to compute Quotient and reminder of two given numbers.

Program

divisor = 5
dividend = 27
quotient = dividend//divisor
reminder = dividend % divisor
print("Quotient is", quotient)
print("Reminder is",reminder)

Output

Quotient is 5
Reminder is 2

First, the numbers are saved in respective variables then to compute quotient we used the floor division // operator that returns the integer value of the quotient and for the reminder, the modulus % operator is used. Later we are just printing out the variables.

Problem Definition

Create a Python program to compute Quotient and reminder of two user-provided numbers in real-time.

Program

divisor = int(input("Enter the divisor"))
dividend = int(input("Enter the dividend"))
quotient = dividend//divisor
reminder = dividend % divisor
print("Quotient is {} and Reminder is {}".format(quotient, reminder))

Output

Enter the divisor 5
Enter the dividend 27
Quotient is 5 and Reminder is 2

Here we are taking input from the user using the  Python's built-in input() method then we are converting it to an integer using the int() method because input() returns the objects as a string object.

Later we are performing the arithmetic operation and printing out the results using string formatting.

Recommended Read

  1. How To Convert Data Types in Python
  2. How To Use String Formatting In Python

PROGRAMS
author's image
Abhijeet Pal Author and Editor in Chief @djangocentral

Abhijeet is a full-stack software developer from India with a strong focus on backend and system design. He is driven by the need to create impactful solutions that add value to the internet in any way possible.

LinkedIn Twitter Github

Latest Articles

Latest from djangocentral

Django 4.1 adds async-compatible interface to QuerySet

The much-awaited pull request for an async-compatible interface to Queryset just got merged into the main branch of Django.Pull Request - https://github.com/django/django/pull/14843 The Django core team has been progressively adding async suppor…
Read more →

3 min read

Making Django Admin Jazzy With django-jazzmin

Django admin is undoubtedly one of the most useful apps of Django. Over the years there has been very little change in the admin app as far as the UX is concerned and it's not a bad thing at all. Django admin was designed to provide a simple and minimali…
Read more →

4 min read