Python Program to find quotient and remainder of two numbers


April 29, 2022, Learn eTutorial
1302

In this simple python program, we need to find the quotient and remainder. It's a beginner-level python program.

To understand this example, you should have knowledge of the following Python programming topics:

How to find quotient and remainder in python?

This simple python program is about the division in arithmetic operation in python. Here we need to divide a number with the given number and print the Quotient and Remainder. For example, consider two numbers 125 and 7, so let us divide 125 with 7, and we get the quotient as 17 and reminder as 6.

To apply the division logic in python language, we accept two numbers from the user, and we are calculating the quotient and remainder separately. For finding the quotient, we divide the number with the given number and save the value to a variable quotient. Secondly, we calculate the remainder using the Mod operator and save that value as a remainder. Finally, print the quotient and remainder using python basic methods and syntax.

ALGORITHM

STEP 1: Accept the two numbers for the division from the user using the input method and convert the string to an integer using int() in the Python programming language.

STEP 2: Save the value of the quotient after the division of the number by the given number.

STEP 3: Save the value for a remainder using the mod operator.

STEP 4: Print the values of quotient and remainder using the print in python.

Python Source Code

                                          a=int(input("Enter the first number: "))

b=int(input("Enter the second number: "))

quotient=a//b

remainder=a%b

print("Quotient is:",quotient)

print("Remainder is:",remainder)
                                      

OUTPUT

Enter the First number : 125

Enter the Second number : 7

Quotient is :  17

Reminder is : 6