Basic Python Operators
Let's look at the different types of Python operators.
We'll cover the following...
Introduction to operators
Operators are tokens that can be used to perform operations such as addition or subtraction. There are several different types of operators in Python, a few of which will be looked at in this lesson.
Over here, the numbers on which the mathematical operation is being applied are called operands and the symbol representing the operation is known as an operator.
It is easier to grasp the figure above using numbers along with an operator. An example of one of the arithmetic operators, the addition operator, can be seen below:
Arithmetic operators
Arithmetic operators are used for carrying out mathematical operations like addition or subtraction.
Except in the case of division (which always yields a float), the result of an operation will be an integer if both the operands are integers. Otherwise, it will be a float.
Addition
In Python, addition can be carried out using the plus (+) symbol.
Subtraction
Subtraction between two operands can be carried out using the negative (-) symbol.
Multiplication
Operands can be multiplied together using the asterisk (*) symbol.
Exponentiation
Exponentiation is an operation that involves raising a number to a power. It is represented by the double asterisk (**) symbol.
Division
Division can be performed using the slash ( ...