Multiplication
What Is Multiplication in Python?
- In Python, the multiplication operator
*is used to find the product of two numbers.
How to Use It:
The basic way to multiply two numbers is:
pythonresult = number1 * number2number1andnumber2are the numbers you want to multiply.resultwill store the product.
Examples and Exercises:
Multiplying Two Numbers:
pythona = 10 b = 12 result = a * b print(result)- Output:
120
- Output:
Chaining Multiplications:
- You can multiply more than two numbers in one line.
pythona = 10 b = 12 c = 5 d = 63 result = a * b * c * d print(result)- Output:
37800
Multiplying Floating Point Numbers:
- You can also multiply numbers with decimals.
pythona = 10.5 b = 12.9 result = a * b print(result)- Output:
135.45
Summary:
- The multiplication operator
*in Python is used to find the product of numbers. It can be used with integers, floating point numbers, and even complex numbers. Try out the examples to get a feel for how it works!