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
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.
Would you like to see your article here on tutorialsinhand.
program by tutorialsinhand.com
About the Author
Full Stack Web Developer & Data Science Enthusiast
Page Views :
Published Date :