Table of Contents
In this tutorial, we will discuss the Python Program to Compute Quotient and Remainder
In this post, we are going to learn how to find quotient and remainder of two numbers using different 3 ways in python.
Program 1
dividend=30 divisor=4 quotient=dividend//divisor; remainder=dividend%divisor; print("Quotient is: ",quotient) print("remainder is: ",remainder)
When the above code is executed, it produces the following result
Quotient is: 7 remainder is: 2
In this program,
Program 2
dividend=int(input("Enter the dividend: ")) divisor=int(input("Enter the divisor: ")) quotient=dividend//divisor; remainder=dividend%divisor; print("Quotient is: ",quotient) print("remainder is: ",remainder)
When the above code is executed, it produces the following result
Enter the dividend: 200 Enter the divisor: 30 Quotient is: 6 remainder is: 20
Program 3
dividend=int(input("Enter the dividend: ")) divisor=int(input("Enter the divisor: ")) def quotient(dividend,divisor): return dividend/divisor; def remainder(dividend,divisor): return dividend%divisor; print("Quotient is: ",quotient(dividend,divisor)) print("remainder is: ",remainder(dividend,divisor))
When the above code is executed, it produces the following result
Enter the dividend: 23 Enter the divisor: 3 ('Quotient is: ', 7) ('remainder is: ', 2)
Approach
Program 4
#Python program to find quotient and remainder using function dividend=999 #Variable Declare and initilaize for dividend divisor=49 #Variable Declare and initilaize for divisor def quotient(dividend,divisor): result= dividend/divisor; print("Quotient is: ",result) #function for find quotient def remainder(dividend,divisor): result= dividend%divisor; print("Remainder is: ",result) #function for find remainder quotient(dividend,divisor) #calling the function for display quotient remainder(dividend,divisor) #calling the function for display remainder
When the above code is executed, it produces the following result
(‘Quotient is: ‘, 20)
(‘Remainder is: ‘, 19)
Program 5
#Python program to find quotient and remainder using function dividend=int(input("Enter the dividend: ")) #Ask input from the user and store the input in dividend variable divisor=int(input("Enter the divisor: ")) #Ask input from the user and store the input in divisor variable def quotient(dividend,divisor): result= dividend/divisor; print("Quotient is: ",result) #function for find quotient def remainder(dividend,divisor): result= dividend%divisor; print("Remainder is: ",result) #function for find remainder quotient(dividend,divisor) #calling the function for display quotient remainder(dividend,divisor) #calling the function for display remainder'''
When the above code is executed, it produces the following result
Enter the dividend: 2000
Enter the divisor: 100
(‘Quotient is: ‘, 20)
(‘Remainder is: ‘, 0)
Suggested post
Similar post
Java Program to Compute Quotient and Remainder
C++ Program to Compute Quotient and Remainder
C Program to Compute Quotient and Remainder
Java Program to divide two numbers
C Program to divide two numbers
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.