Articles

Python program to divide two numbers

Python program to divide two numbers


In this python programs guide, we will learn to:

  • write a program in python to find quotient and remainder after division

Program in python to find quotient and remainder after division

Given below is a code snippet to write a python program to divide two numbers (by taking fixed values). And we will also find quotient as well.

# Owner : TutorialsInhand Author : Devjeet Roy

n1 = int(input("Enter first number: "))
n2 = int(input("Enter second number: "))

quotient = n1/n2
remainder = n1 % n2

print("The quotient is:",quotient);
print("The remainder is:",remainder);

The output of the python program to divide two numbers is as follows:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py   
Enter first number: 30
Enter second number: 5
The quotient is: 6.0
The remainder is: 0

Please check our video tutorial on python program to divide two numbers:

 

 

Few important points about this program:

1. To find the quotient we use the "/" operator in Python. But it returns the output in float datatype. So, to get the output as an integer, we should use "//" instead of "/" in Python.

2. To find the remainder we use the "%" operator in Python.

3. We can ignore storing value in the variable by directly performing mathemtical computations in the print() statement.

 

write a program in python to find quotient and remainder after division

 


Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :    Published Date : May 03,2023  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!