Find division of two numbers
Table of Contents
In this tutorial, we will discuss the Python program to Divide two integers|in 5ways
In this post, we are going to learn how to find division of two numbers using different 5 ways in Python language
Program 1
num1=250
num2=25
div=num1/num2;
print("The division of {0} and {1} is: {2}".format(num1,num2,div)) When the above code is executed, it produces the following result
The division of 250 and 25 is: 10
Program 2
num1=input("Enter the first number: ")
num2=input("Enter the second number: ")
div=num1/num2;
print("The division of {0} and {1} is: {2}".format(num1,num2,div)) When the above code is executed, it produces the following result
Enter the first number: 2400 Enter the second number: 80 The division of 2400 and 80 is: 30
Approach
Program 3
#python program to divide two numbers using function
def divNum(a,b):#function definision for division
divide=a/b
return divide
num1=int(input("input the number 1 : "))#input from user to num1
num2=int(input("input the number 2 : ")) #input from user to num2
print("The division is",divNum(num1,num2))#call the function When the above code is executed, it produces the following result
input the number 1 : 450 input the number 2 : 30 The division is', 15
Approach
Program 4
#python program to divide two numbers using function
def divNum(x,y):#function definision for division
if (y==0):
return 0;
elif (x-y==0):
return 1;
elif (x<y):
return 0;
else:
return (1+divNum(x-y,y));
num1=int(input("input the number 1 : "))#input from user to num1
num2=int(input("input the number 2 : ")) #input from user to num2
print("The division is",divNum(num1,num2))#call the function When the above code is executed, it produces the following result
input the number 1 : 1000
input the number 2 : 40
('The division is', 25)
Approach
Suggested post
Similar post
C program to calculate division of two numbers | 6 different Methods
C++ program to calculate division of two numbers | 6 different Methods
Java program to calculate division of two numbers | 5 different Methods
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.