Python Program to find quotient and remainder using function
- Home
- Calculations
- Python Program to find quotient and remainder using function
- On
- By
- 0 Comment
- Categories: Calculations, Operators
Python Program to find quotient and remainder using function
Python Program to find quotient and remainder using function
In this tutorial, we will discuss the concept of Python Program to find quotient and remainder using function of two numbers When the one number divided by another
In this topic, we are going to learn how to calculate quotient and remainder of two numbers using function in Python programming language
What is quotient and remainder
To find the quotient, we have used the division(/) operator. we have divided (dividend by divisor) two numbers one by another
To find remainder, we have use modular(%) operator . The dividend is divided by the divisor and the remainder is returned by the modular(%) operator
Python program to find quotient and remainder
Program to find quotient and remainder using function
Program 1
In this program, the user initialize two integer numbers using two variables as quotient and remainder and then the program calculates the quotient and remainder of the given numbers using function in python language
#Python program to find quotient and remainder using function dividend=600 #Declare and initilaize variable dividend divisor=35 #Declare and initilaize variable 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: 17 Remainder is: 5
Program to find quotient and remainder using function – entered by user
The program allows to enter two integer and then the program calculates the quotient and remainder of the given numbers using function in Python language
Program 2
#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: 100 Enter the divisor: 8 Quotient is: 12 Remainder is: 4
Program to find quotient and remainder using function – entered by user using return
The program allows to enter two integer and then the program calculates the quotient and remainder of the given numbers using function in Python programming language with return keyword
Program 3
#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): return dividend/divisor; #function for find quotient def remainder(dividend,divisor): return dividend%divisor; #function for find remainder print("Quotient is: ",quotient(dividend,divisor))#calling the function #display quotient print("remainder is: ",remainder(dividend,divisor))#calling the function #display remainder
When the above code is executed , it produces the following result
Enter the dividend: 125 Enter the divisor: 20 Quotient is: 6 remainder is: 5
Suggested for you
Introduction of Python Language
Similar post
C Program to Divide of two integer numbers
Java Program to Divide of two integer numbers
C++ Program to Divide of two integer numbers
Python Program to Divide of two integer numbers
C Program to Divide of two integer numbers using function
Java Program to Divide of two integer numbers using method
C++ Program to Divide of two integer numbers using function
Python Program to Divide of two integer numbers using function
Java code to calculate quotient and remainder
C code to calculate quotient and remainder
C++ code to calculate quotient and remainder
Python code to calculate quotient and remainder