Skip to main content

Arithmetic Operators

tip

Now that you've learned how to write and execute your own Python code, try out the things you've learned in this section by yourself.

Practice makes perfect!

Knowing how to perform simple arithmetic to your variables in Python is going to be a vital part of almost any code that you are writing.

Here are the Arithmetic Operators

OperationSyntaxDescriptionExample
(+ output)
Additiona + bAdds a and b together1 + 1 = 2
Subtractiona - bSubtracts b from a3 - 2 = 1
Multiplicationa * bMultiplies a and b72 * 2 = 142
Divisiona / bDivides a and b17 / 4 = 4.25
Integer Divisiona // bDivides a and b, rounded down17 // 4 = 4
Exponentiationa ** bRaises a to the power of b2 ** 4 = 16
Modulusa % bProduces a modulo b

a % b produces the remainder of dividing a by b
17 % 4 = 1