Header Ads

Python Program to Read Two Numbers and Print Their Quotient and Remainder

Python Program to Read Two Numbers and Print Their Quotient and Remainder

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)

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





Powered by Blogger.