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
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.