# Python Operators with examples

Operators are the constructs that are used to manipulate the value of operands. Some basic operators include +, -, *, and / . In an expression, an operator is used on operand(s) (values to be manipulated). For example, in the expression sum = a + b, a and b are operands and + is the operator.

Python Supports different types of operators which are as follows –

1. Arithmetic Operators
2. Comparison Operators
3. Assignment Operators
4. Logical Operators
5. Bitwise Operators
6. Membership Operators
7. Identity Operators

## 1 . Arithmetic Operators –

Some basic arithmetic operators are +, -, *, /, %, ** and //. You can apply these operators on numbers as well as on variables to perform corresponding operations. For example if a=100 and b=200, then look at the below table to see the result of operations.

## 2 . Comparison Operators –

Comparison operators also known as relational operators are used to compare the values on its either sides and determines the relation between them. For example assuming a = 100 and b = 200, we can use the comparison operators on them as specified in the below table.

## 3 . Assignment Operators –

Assignment operator as the name suggests assigns value to the operand. The in-place operators also known as shortcut operators that includes +=, -=, *=, /=, %=, //= and **= allow you to write code like num = num + 10 more concisely as num += 10. The different types of assignment and in-place operators are given in the table below.

## 4. Bitwise Operators –

As the name suggests, bitwise operators performs operations at the bit level. Bitwise operators expect their operands to be of integers and treat them as a sequence of bits.

## 5 . Logical Operators –

Logical operators are used to combine conditional statements.

## 6. Membership Operators –

Membership operators are used to test if a sequence is presented in an object.

## 7. Identity Operators –

Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location.

## Operators Precedence and Associativity –

The below table lists all operators from highest precedence to lowest. When an expression has more than one operator then it is the relative priorities of the operators with respect to each other that determine the order in which the expression will be evaluated.

Rating: 1 out of 5.