# What are Python Operators?

Python operators are special types of functions that perform certain, mostly mathematical, operations in the Python programming language.

### What are Operators?

In Python, there are the so-called operators, which, like a function, execute fixed-defined actions. However, a function does not have to be defined in a conventional way, but much shorter operators can be used. Python operators are already installed in the basic version of Python and do not have to be added by importing an additional module.

More generally, a Python operator consists of the left side, the operator, and the right side. The operator determines what happens to the right and left sides. Depending on the source, this is also referred to as the operands. We will use this term in this article.

There are countless operators in Python which we will discuss further in the following chapters. One of them is the mathematical difference, which can be called using the character “-“.

In our example, the minus sign is the operator. The two operands are the numbers nine and three. Finally, the number six is the result of the operation.

### What are the types of Python Operators?

Python distinguishes between different types of operators, which we will explain in more detail in the following chapters.

#### Comparison Operators

The comparison operators can compare two operands with each other. They always return a Boolean value (True or False) as the result.

#### Arithmetic / Mathematical Operators

The mathematical or arithmetic operators implement basic mathematical functions in Python. For this, the basic calculation types, such as sum, difference, multiplication, etc. are covered.

#### Logical Operators

The logical operators are also from mathematics and enable the connection of conditions with the help of the logical And and Or. Two statements linked with “or” are true exactly when one of the two statements is true. Two statements linked with “and” are true exactly when both statements are true.

#### Identity Operator

The Python operator “is” is used to check whether two variables have the same value assigned to them. The operator then returns True or False accordingly. This can also be used to check dynamically in a script whether the variables are identical.

#### Subset Operator

The subset operators can be used to check whether one or more elements are present in a set, such as a Python List.

The negation can be used to check the opposite, i.e. whether the element is not part of the set.

#### Assignment Operators

We already know the most basic assignment operator from the definition of a variable. With the help of the “=” we can assign a value to a variable. In addition, there are other assignment operators with the help of which, for example, sums or products can be written in a shortened form.

### This is what you should take with you

• Python operators are special types of functions that mostly perform mathematical functions.
• Python operators allow quick invocation without the need to define a new function.
• There are different types, such as logical operators or assignment operators.