Arithmetic Operators

Name

Symbol

Syntax

Explanation

+

Addition

var_1 + var_2

var_1 and var_2 are added together

-

Subtraction

var_1 - var_2

var_2 is subtracted from var_1

*

Multiplication

var_1 * var_2

var_1 and var_2 are multiplied together

/

Division

var_1 / var_2

The quotient of var_1 divided by var_2; the result is always a float

//

Floor Division

var_1 // var_2

The quotient of var_1 divided by var_2; the result is dependent on the values passed

**

Exponent / Power

var_1 ** var_2

var_1 is raised to the power of var_2

%

Modulo

var_1 % var_2

The remainder when var_1 is divided by var_2

For demonstration purposes, let’s take two numbers: num_one, which will be made equal to 6, and num_two, which will be made equal to 3. Applying the operations above would give the following results:

Addition

Adding 6 and 3 would result in 9.

Expression: 6 + 3 

Subtraction

Subtracting 3 from 6 would result in 3.

Expression: 6 - 3 

Multiplication

Multiplying 6 and 3 would result in 18.

Expression: 6 * 3 

Division

Dividing 6 by 3 using the / operator would result in 2.0 (always a float).

Expression: 6 / 3

Floor division

Dividing 6 by 3 using the // operator would result in 2 (since 6 and 3 are integers).

Expression: 6 // 3 

Power

6 to the power of 3 would result in 216.

Expression: 6 ** 3

Modulo

6 divided by 3 would result in a remainder of 0.

Expression: 6 % 3

Code

We can effectively put this into Python code, and you can even change the numbers and experiment with the code yourself! Click the “Run” button to see the output.

num_one = 6
num_two = 3
addition = num_one + num_two
print(addition)
subtraction = num_one - num_two
print(subtraction)
multiplication = num_one * num_two
print(multiplication)
division = num_one / num_two
print(division)
floor_division = num_one // num_two
print(floor_division)
power = num_one ** num_two
print(power)
modulo = num_one % num_two
print(modulo)