Multiplication of two numbers
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
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.