We will develop a Python program for multiplication of two numbers. A mathematical operation is performed on a pair of numbers in order to derive a third number called a product. We will give two numbers num1 and num2. Then, calculate the product of those numbers using the **multiplication operator (*)**. Here, we will calculate the product of two numbers using various methods.

**How to find the product of two number:**

Product = a x b

**Mathematically,**

Inputs: a=2, b=5

Product = a x b = 2 x 5 = 10

## Python Program to Multiply Two Numbers

This is the simplest and easiest way to multiply two numbers in Python. We will take two numbers while declaring the variables and calculate the product of these numbers. Its multiplication value will be stored in the product variable and finally, the multiplication value will be displayed on the screen.

Program description:- **Write a Python program to accept two numbers multiply them and print the result**

```
# Python program to multiply two number
# take inputs
num1 = 3
num2 = 5
# calculate product
product = num1*num2
# print multiplication value
print("The Product of Number:", product)
```

Output:-

The Product of Number: 15

## Python Program for Multiplication of Two Numbers

In the previous program, inputs are hardcoded in the program but in this program, inputs will be provided by the **user**. Inputs are scanned using the **input() function** and stored in variable num1, and num2.

Program description:- **Write a Python program to ask from the user two numbers and print their product**

```
# Python program to multiply two number
# take inputs
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
# calculate product
product = num1*num2
# print multiplication value
print("The Product of Number: %0.2f" %product)
```

Output for the different input values:-

Enter first number: 15

Enter second number: 8

The Product of Number: 120.00

Enter first number: 23

Enter second number: 6.5

The Product of Number: 149.50

Enter first number: 12.4

Enter second number: 21.9

The Product of Number: 271.56

## Python Program to Multiply Two Numbers using Function

We can also take the help of a function to multiply two numbers in python. A **function** is a block of code that performs a specific task.

```
# Python program to multiply two numbers using function
def product_num(num1, num2): #user-defind function
num = (num1 * num2) #calculate product
return num #return value
# take inputs
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
# function call
product = product_num(num1, num2)
# print multiplication value
print("The Product of Number: %0.2f" %product)
```

Output:-

Enter first number: 153

Enter second number: 23.5

The Product of Number: 3595.50

## Product of Two Numbers in Python using Recursion

A function/method that contains a call to itself is called the recursive function/method. A technique of defining the recursive function/method is called recursion. The recursive function/method allows us to divide the complex problem into identical single simple cases that can be handled easily. This is also a well-known computer programming technique: divide and conquer.

```
# Python program to multiply two number using recursion
def product_num(num1,num2): #user-defined function
if(num1<num2):
return product_num(num2,num1)
elif(num2!=0):
return(num1+product_num(num1,num2-1))
else:
return 0
# take inputs
num1 = int(input('Enter first number: '))
num2 = int(input('Enter second number: '))
# function call
product = product_num(num1, num2)
# print multiplication value
print("The Product of Number:", product)
```

Output:-

Enter first number: 20

Enter second number: 5

The Product of Number: 100

## Python Program to Multiply Two Numbers Without using Operator

This python program also performs the same task but with different methods. In this program, we are using the **For Loop** to calculate the product of those numbers.

```
# Python program to multiply two number using for loop
# take inputs
num1 = int(input('Enter first number: '))
num2 = int(input('Enter second number: '))
# calculate product
product = 0
for i in range(1,num2+1):
product=product+num1
# print multiplication value
print("The Product of Number:", product)
```

Output:-

Enter first number: 16

Enter second number: 5

The Product of Number: 80