Python Program to Multiply Three Numbers

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

How to find the product of three number:
Product = a x b x c

Mathematically,

Inputs: a=2, b=5, c=8
Product = a x b x c = 2 x 5 x 8= 80

Python Program for Multiplication of Three Numbers

This is the simplest and easiest way to multiply three numbers in Python. We will take three 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 program in python to find out the product of three numbers a, b, and c entered by the user at run time with the output

# Python program to multiply three number

# take inputs
a = 2
b = 3
c = 5

# calculate product
product = a * b * c

# print multiplication value
print("The Product of Number:", product)

Output:-

The Product of Number: 30

Product of Three Numbers in Python

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, num2, and num3.

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

# Python program to multiply three number

# take inputs
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
num3 = float(input('Enter third number: '))

# calculate product
product = num1 * num2 * num3

# print multiplication value
print("The product of number: %0.2f" %product)

Output for the different input values:-

Enter first number: 3
Enter second number: 8
Enter third number: 15
The product of number: 360.00

Enter first number: 5
Enter second number: 12.6
Enter third number: 25
The product of number: 1575.00

Enter first number: 3.5
Enter second number: 12.4
Enter third number: 30.7
The product of number: 1332.38

Python Program to Multiply Three Numbers using Function

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

# Python program to multiply three numbers using function

def product_num(num1, num2, num3):  #user-defind function
    num = (num1 * num2 * num3)   #calculate product
    return num   #return value

# take inputs
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
num3 = float(input('Enter third number: '))

# function call
product = product_num(num1, num2, num3)

# print multiplication value
print("The product of number: %0.2f" %product)

Output:-

Enter first number: 25
Enter second number: 0.4
Enter third number: 3
The product of number: 30.00

Also See:- Find the Average of 3 Numbers in Python

Leave a Comment

Your email address will not be published. Required fields are marked *