لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Lesson 12: Arithmetic Operators in Python

Arithmetic Operators are special symbols in Python that carry out arithmetic or logical computation. The value that the operator operates on is called the operand.

Operator Name
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
** Exponentiation
// Floor division

Example; Addition

x = 7
y = 3
print(x + y)
the output is
10

Example; Subtraction

x = 7
y = 3
print(x - y)
the output is
4

Example; Multiplication

x = 7
y = 3
print(x * y)
the output is
21

Example; Division
x = 7
y = 3
print(x / y)
the output is
2.3333333333333335

Example; Modulus
x = 7
y = 3
print(x % y)
the output is
1

Example; Exponentiation x = 7
y = 3
print(x ** y)
the output is
343
(# same as 7*7*7)

Example; Floor division x = 7
y = 3
print(x // y)
the output is
2
(# the floor division // rounds the result down to the nearest whole number)