| March 28, 2024, 9:37 a.m.
Let's continue the Python series and talk about operators. There are some different types of operators but we start with the arithmetic ones.
Arithmetic Operators:
Addition (+): Adds two operands.
result_add = 5 + 3print(result_add) #outputs 8
Subtraction (-): Subtracts the right operand from the left operand.
result_sub = 10 - 3print(result_sub) #outputs 8
Multiplication (*): Multiplies two operands.
result_mult = 6 * 7print(result_mult) #outputs 42
Division (/): Divides the left operand y the right operand(always results in a float).
result_div = 15 / 3print(result_div) #outputs 5.0
Floor Division (//): Divides the left operand by the right operand and returns the integer part of the result.
result_floor_div = 16 // 3print(result_floor_div) #outputs 5
Modulus (%): Returns the remainder of the division of the left operand by the right operand.
result_mod = 16 % 3print(result_mod) #outputs 1
Exponentiation (**): Raises the left operand to the power of the right operand.
result_exp = 2 ** 5print(result_exp) #outputs 32
In the next blog post we are going to go through variables and assignment operators.
Enjoy!