Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
C++ Program to Compute Quotient and Remainder

Python Program to Compute Quotient and Remainder

Posted on September 12, 2020May 24, 2021

Table of Contents

  • Python Program to Compute Quotient and Remainder
    • Program to Compute Quotient and Remainder – standard method
    • Program to Compute Quotient and Remainder -using  user input
    • Program to Compute Quotient and Remainder -using  function

Python Program to Compute Quotient and Remainder

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 to Compute Quotient and Remainder – standard method

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,

  • integer variables dividend and divisor are declared and initialized
  • integer variables quotient and remainder are declared.
  • The dividend and divisor both are used to calculate quotient and remainder
  • Then,the program is displayed the output of using print() function.

 

Program to Compute Quotient and Remainder -using  user input

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

 

  • integer variables dividend and ,divisor are declared
  • integer variables quotient and remainder are declared.
  • The program asks input from the user
  • Then the user enters the input values for dividend and divisor.
  • The program will read the input using input stream and store the variables dividend and divisor respectively
  • The dividend and divisor both are used to calculate quotient and remainder.
  • Then,the program is displayed the output of using printf() function

 

Program to Compute Quotient and Remainder -using  function

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

  • Integer variable dividend and ,divisor both are declared,
  • The program takes input from the user
  • Then the user enters the input value for dividend and ,divisor
  • The program will read the input value and store the variables in  dividend and divisor.
  • Define the two function for finding quotient and remainder , separately
  • When we call the function, The dividend and divisor both are used to calculate quotient and remainder.
  • Finally the program is displayed the output using print() function.

 

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

Function in Python language

Operator in Python language

Data type in Python

 

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

C++ Program to divide two numbers

Python Program to divide two numbers

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes