# Operators in Python | Types of Operators in Python with Example

Operators in python with example. Arithmetic operator, logical operator, comparison operator, identity operator, membership and bitwise operator.

In this post we will learn about what is operator and different types of operators in Python.

# What is an Operator?

An operator is a special symbol which is use to perform operation on variable or values.

### Types of Operators in Python

#### Python Arithmetic Operators

Arithmetic operators in python is used to perform mathematical calculations like addition, subtraction, multiplication etc.

SymbolOperationExample
-Subtractionx - y
*Multiplicationx * y
/Divisionx / y
%Modulusx % y
**Exponentx ** y
//Floor Divisionx // y

#### Python Comparison Operators

The comparison operator in python is used to compare two operands.

SymbolOperationExample
==Equalx == y
!=Not equalx != y
>Greater thanx > y
<Less thanx < y
>=Greater than equal tox >= y
<=Less than equal tox <= y

#### Python Logical Operators

The logical operator in python is used to perform logical operations on two values or variables. It is used in conditional statement that is either true or false.

SymbolOperationExample
andReturns true if both the conditions are truex < 8 and x < 10
orReturns true if any one condition is truex < 6 or x < 10
notReturns true if the result is false and vice versanot(x < 6 or x < 10)

#### Python Identity Operators

Python identity operator is used to compare two objects not only if they are equal but also make sure that both the objects are equal with same memory location.

SymbolOperationExample
isReturns true only if both the variables are same objectx is y
is notReturns true only if both the variables are not same objectx is not y

#### Python Membership Operator

The membership operator in python is used to validate the membership of value.

SymbolOperationExample
inReturns true if the sequence with the specified value is present in the objectx in y
not inReturns true if the sequence with the specified value is not present in the objectx in not y

#### Python Bitwise Operators

Bitwise operator in Python is used to perform action on bit level programmimg.

SymbolOperationDescription
& ANDSet each bit to 1 if both bits are 1
|ORSet each bit to 1 if one of the two bits is 1
^XORSet each bit to 1 if only one of the two bits is 1
~NOTInverts all bits
<<Left Shift
>>Right Shift

#### Python Assignment Operators

The assignment operator in python is used to assign values to the variable.

SymbolOperationExample
=x = 10x = 10
+=x = x + 10
-=x = x - 10x -= 10
*=x = x * 10x *= 10
/=x = x / 10x /= 10
%=x = x % 10x %= 10
//=x = x // 10x //= 10
**=x = x ** 10x **= 10
&=x = x & 10x &= 10
|=x = x | 10x |= 10
^=x = x ^ 10x ^= 10
>>=x = x >>= 10x >>= 10
<<=x = x <<= 10x <<= 10