Practice With Arithmetic Operators

Practice these programming examples to internalize these concepts.

2. Operators

An operator is a symbol or function that indicates an operation. For example, in math the plus sign or + is the operator that indicates addition.

In Python, we will see some familiar operators that are brought over from math, but other operators we will use are specific to computer programming.

Here is a quick reference table of math-related operators in Python. We'll be covering all of the following operations in this tutorial.

Operation What it returns
x + y Sum of x and y
x - y Difference of x and y
-x Changed sign of x
+x Identity of x
x * y Product of x and y
x / y Quotient of x and y
x // y Quotient from floor division ofx and y
x % y Remainder ofx / y
x ** y x to the y power

We'll also be covering compound assignment operators, including += and *=, that combine an arithmetic operator with the = operator.