Multiplication - Python Examples
Python Multiplication - Arithmetic Operator
Python Multiplication Operator takes two operands, one on the left and other on the right, and returns the product of the these two operands.
The symbol used for Python Multiplication operator is *
.
Syntax
Following is the syntax of Python Multiplication Arithmetic Operator.
result = operand_1 * operand_2
where operand_1
and operand_2
are numbers and the result is the product of operand_1
and operand_2
.
Example 1: Multiplication of Numbers
In this example, we shall take two integers, multiply them, and print the result.
Python Program
a = 10
b = 12
result = a * b
print(result)
Output
120
Chaining of Multiplication Operator
You can multiply more than two numbers in a single statement. This is because, Multiplication Operator supports chaining.
Python Program
a = 10
b = 12
c = 5
d = 63
result = a * b * c * d
print(result)
Output
37800
Example 2: Multiplication of Floating Point Numbers
Float is one of the numeric datatypes. You can compute the product of floating point numbers using Python Multiplication operator. In the following example, we define two floating point numbers, and find their product.
Python Program
a = 10.5
b = 12.9
result = a * b
print(result)
Output
135.45000000000002
Example 3: Multiplication of Complex Numbers
You can find the product of complex numbers. In the following example program, we shall take two complex numbers and find the result of their multiplication.
Python Program
a = 1 + 8j
b = 3 + 5j
result = a * b
print(result)
Output
(-37+29j)
Summary
In this tutorial of Python Examples, we learned what Python Multiplication Arithmetic Operator is, how to use it to find the product of two or more numbers.