Basic Operators

This will explain how to use basic operators within Python.

Arithmetic Operators
These include operators such as addition, subtraction, multiplication and division.

You can add by using "+" in between two numbers.

You can subtract by using "-" in between two numbers.

You can divide by using "/" in between two numbers.

You can multiply by using "*" in between two numbers.

MOD and DIV
There are also operators that can return the remainder value of a calculation and can show you how many numbers fit into one number. MOD (Modulo) is a "%" symbol and DIV (Divison) is a "//"

Examples of this are:

remainder = 10 % 3

* This would make the variable 1 as there is one left over when dividing 10 by 3*

amount = 20 // 2

* This would make the variable 10 as there are ten 2's that can go into 20*

Powers
Placing two asterisks in between two numbers will make the first number to the power of the second.

This means 7 ** 2 is 7 Squared (49) and 7 ** 3 is 7 Cubed (343)

Certain operators can be used with strings such as the "+" operator and can also be used with Lists to add two lists together.

Continue to the next lesson.