Compute Quotient and Remainder
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
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.