Python Program to Find Quotient and Remainder of Two Numbers

This is a Python Program to read two numbers and print their quotient and remainder.

Problem Description

The program takes two numbers and prints the quotient and remainder.

Problem Solution

1. Take in the first and second number and store it in separate variables.
2. Then obtain the quotient using division and the remainder using modulus operator.
3. Exit.

Program/Source Code

Here is the source code of the Python Program to read two numbers and print their quotient and remainder. The program output is also shown below.

 
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)
Program Explanation

1. User must enter the first and second number .
2. The quotient is obtained using true division (// operator).
3. The modulus operator gives the remainder when a is divided by b.

advertisement
advertisement
Runtime Test Cases
 
Case 1:
Enter the first number: 15
Enter the second number: 7
Quotient is: 2
Remainder is: 1
 
Case 2:
Enter the first number: 125
Enter the second number: 7
Quotient is: 17
Remainder is: 6

Sanfoundry Global Education & Learning Series – Python Programs.

To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.