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:

    python
    result = number1 * number2
    
    • number1 and number2 are the numbers you want to multiply.
    • result will store the product.

Examples and Exercises:

  1. Multiplying Two Numbers:

    python
    a = 10
    b = 12
    result = a * b
    print(result)  
    • Output: 120
  2. Chaining Multiplications:

    • You can multiply more than two numbers in one line.
    python
    a = 10
    b = 12
    c = 5
    d = 63
    result = a * b * c * d
    print(result)  
    • Output: 37800
  3. Multiplying Floating Point Numbers:

    • You can also multiply numbers with decimals.
    python
    a = 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!