Table of Contents
In this tutorial, we will discuss the Python program to Multiply two integers|in 5ways
In this post, we are going to learn how to find multiplication of two numbers via different 5 ways in Python language
Program 1
#Python program to mutipy two numbers num1=15 num2=16 mul=num1 * num2; print("Multiplication of two numbers: ",mul)
When the above code is executed, it produces the following result
Multiplication of two numbers: 240
Program 2
#Python program to mutipy two numbers num1=int(input("Enter first number: ")) num2=int(input("Enter second number: ")) #input numbers from the user mul=num1 * num2;#caculate multipication print("Multipication of two numbers: ",mul) #display output
When the above code is executed, it produces the following result
Enter first number: 12 Enter second number: 24 Multiplication of two numbers: 288
Approach
Program 3
#Python program to multiply two numbers using function def multiply(num1,num2):#function definition product=num1 * num2 return product num1=int(input("Enter first number ")) num2=int(input("Enter second number ")) #input numbers from the user result=multiply(num1,num2)#caling the function print("Multipication of two numbers: ",result) #display output
When the above code is executed, it produces the following result
Enter first number 12 Enter second number 21 Multiplication of two numbers: 252
Approach
Program 4
def product(x,y): if(x<y): return product(y,x) elif(y!=0): return (x+product(x,y-1)) else: return 0 x=int(input("Enter first number: ")) y=int(input("Enter second number: ")) print("Product is ", product(x,y))
When the above code is executed, it produces the following result
Enter first number: 100 Enter second number: 50 ('Product is ', 5000)
Approach
Program 5
num1=int(input("Enter first number: ")) num2=int(input("Enter second number: ")) product=0 for i in range(1,num2+1): product=product+num1 print("Product is ", product)
When the above code is executed, it produces the following result
Enter first number: 50 Enter second number: 60 Product is 3000
Suggested post
Similar post
Find product of two numbers in Java language|5ways
Find product of two numbers in C language|6ways
Find product of two numbers in C++ language|6ways
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.