### Python Operators

We know that an operator is a symbol which performs an operation. An operator acts upon which data items is known as operands.

Python supports seven following operators which are as follows: 1. Arithmetic operators
2. Comparison operators
3. Logical operators
4. Bitwise operators
5. Assignment operators
6. Identity operators
7. Membership operators

Python Arithmetic Operators

Python Arithmetic operators are specifically used with numeric values to perform mathematical operations like addition, subtraction, multiplication, division, modulo and to the power.

Example: Note:

Here there are 2 division operators like division( / ) and floor division(//). Division( / ) meant for floating value and floor division meant for decimal value(that is quotient value).

5/3=1.6666666666666667

5//3=1

In general both / and // are called division operator. One(/) is meant for floating value and another (//) is meant for decimal value.

Python Comparison Operators

Comparison operators are used to compare two values: Here the output value is a boolean value(True or False).

The comparison operators are : < <= > >= != == (less than, less than equals to, greater than, greater than equals to, not equals to, double equals to).

Example: Python Logical Operators  Python Bitwise Operators

Python bitwise operators are bitwise and(&), bitwise or(|), bitwise not(~), bitwise xor(^), left shift(<<), right shift(>>).Bitwise operators are used to compare (binary) numbers.

Example: Note:

Here in case of left shift operator, we evaluate expression by using a direct formula that is input value * 2 to the power no. of shifting values and in case of right shift operator, input value // 2 to the power no. of shifting values.

x<<3 that means 5*23 =40

x>>2 that means 5//22 =1

Python Assignment Operators

Assignment operators are used in Python to assign values to variables.

`x =100` that means the value 100 is assigning to x

There are various compound assignment operators in Python like `x += 50` that adds to the variable and later assigns the same. It is equivalent to `x = x + 50`.

Example: Python Identity Operators

`is` and `is not` are the identity operators in Python. These are used to check if two values (or variables) are located on the same part of the memory. Two variables that are equal does not imply that they are identical.

Example:  Python Membership Operators

`in` and `not in` are the membership operators in Python. These operators are used to test whether a value or variable is found in a sequence (string, list, tuple, set and dictionary). In a dictionary we can only test for presence of key, not the value.

Example:  Silan Software

Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc