Python Program to Read Two Numbers and Print Quotient and Remainder
In this example, we will write a simple program that takes input from the user and calculates the quotient and remainder operation in Python. The quotient is the result of the division operation while the remainder is the value remaining after the division operation. To better understand this example, make sure you have knowledge of the following tutorials:-
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)
The output of the above program is:-
Enter the first number: 16
Enter the second number: 3
Quotient is: 5
Remainder is: 1
Enter the second number: 3
Quotient is: 5
Remainder is: 1
In this program, the user input is taken using input() function which takes input as a string. But as we are doing the calculation part, we need the input to be an integer. So, we did the type-conversion using int() function.
The input from the user is taken as a and b and the operator // is used for calculating quotient and % for calculating remainder. The result is displayed using print () function.