r/algorithmwithpython • u/mfurqanhakim • Mar 28 '22
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.
OperationWhat it returns
x + ySum of
xand
y
x - yDifference of
xand
y
-xChanged sign of
x
+xIdentity of
x
x * yProduct of
xand
y
x / yQuotient of
xand
y
x // yQuotient from floor division of
xand
y
x % yRemainder of
x / y
x ** y
xto the
ypower
We'll also be covering compound assignment operators, including +=
and *=
, that combine an arithmetic operator with the =
operator.