Multiplying and dividing numbers in Python is really straightforward. If you've ever multiplied or divided numbers in other coding languages, you'll find the process for doing so in Python is really similar, if not pretty much exactly the same. Understanding how to multiply and divide numbers in Python is important, not because you need to know the answer to something like 2 times 2, but because you can use these operations in your more complex code to achieve other functionalities.

To multiply two numbers by each other, you'll use the "*" operator, like this:

2*4 5*10 3*7

That's just about all it takes to perform some multiplication. Don't forget that if you want to print the results of the numbers you're multiplying, you'll have to use the print command, like this:

print(2*4) print(5*10) print(3*7)

The output of the code above would be:

8 50 21

Dividing numbers is similarly straightforward. The syntax is similar to the one you'd use to multiply numbers, except instead of using the * operator, you use the "/" operator. Just like when dividing numbers using any other programming language (or even using a calculator, for that matter), put the number you want to be divided in front of the slash, and the number you want to divide it by after the slash.

Here's how your division should look:

8/2 16/8 20/4

And if you want it printed, do the same as we did to the multiplication equations above:

print(8/2) print(16/8) print(20/4)

The output for the code above should be this:

4 2 5

Now that you understand the basics of multiplication and division in Python, you can use the concept in your more complicated functions, use it in your loops, and see just how much you can do with a simple operator like * or /. If you want to learn how to use another operator to calculate the remainder of when one number is divided by another, check out our tutorial on how to use the modulo operator.