# Python Operators – All types with examples.

An operator is a special symbol that operates over variables, values, and other types. On success, it gives an outcome. For example + is an arithmetic operator that applies on two operands and the result is the sum of two values. In this tutorial, you will learn, all types of operators in Python with examples.

## What are all types of operators in Python?

• Arithmetic Operators ( +, – , * etc.) – For basic mathematical operations, add, subtract etc.
• Relational Operators (>, < , == etc.) – For comparing values.
• Logical Operators (and, or etc) –
• Assignment Operators ( =, +=, etc) –
• Bitwise operators (|, & etc.) –
• Identity Operator –
• Membership Operator.

## What Arithmetic Operators do?

They are used for basic mathematical functionality, such as additional, multiplication, subtraction, etc. The following table list all arithmetic operators.

## Relational Operators – Compare two Operands

Using a relation operator, you can compare two values. The result is a boolean value, either True or False. The following table lists all compare operators in Python.

## Assignment Operators – Update or Initialize the content of a variable.

With assignment operators, you can set the value of a variable. Works on two (left and right) operands. The left side is a variable, the right side could be, expression, a constant, or another variable. Following is the list of all assignment operators in Python.

## Bitwise operators – Works at the bit level

A bit operator works on an individual bit level. For example, when we do a bitwise or of two variables, each bit at the same positions from each variable is ORRED and resulting bits are returned. Below is the list of all bitwise operators.

## Identity and Membership Operators:

Identity operators are special operators. There are two identity operators, `is` and `is not`. With is not we compare the two memory locations. Following is an example.

``````X = 5;
Y = 6;
Z = 6;

print(X is not Y)
print(X is Z)
print(Y is Z)``````

Output->

```True
False
True```

## Membership Operators – To check if a value belongs to a sequence?

`in `and `not in` are the two membership operators, to find the presence of a value in the sequence e.g string, tuple, dictionary, etc.
`in` – Returns true if a value is present.
`not in `– Returns True if a value is absent.

``````String = 'Hello Python';

print('P' in String);
print('K' not in String);
print('Z' in String);``````

Output->

```True
True
False```