# Python Operators

Operators are used to perform certain operations in programming languages. These are nothing but symbols. Python provides the following set of operators.

• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators

## Arithmetic Operators

Arithmetic operators are used with numeric values to perform mathematical operations.

`Practice these in your Python IDLE.a=10b=2print('a+b=', a+b)print('a-b=', a-b)print('a*b=', a*b)print('a/b=', a/b)print('a%b=', a%b)print('a//b=', a//b)print('a**b=', a**b)`

## Assignment Operators

You can use assignment operator to assign value to the variable.

`Practice these in your Python IDLE.x = 5print(x)print(x += 10)print(x -= 10)print(x *= 10)print(x /= 10)print(x %= 10)print(x //= 10)print(x **= 10)print(x &= 10)print(x |= 10)print(x ^= 10)print(x >>= 10)print(x <<= 10)`

## Comparison Operators

These operators are used to compare two arguments.

`Practice these in your Python IDLE.a = 5b = 10print(x == y)print(x != y)print(x > y)print(x < y)print(x >= y)print(x <= y)`

## Logical Operators

You can use Logical operators to combine conditional statements.

`Practice these in your Python IDLE.x = 5print(x < 15 and x < 20)print(x < 15 or x < 14)print(not(x < 15 and x < 20))`

## Identity Operators

You can compare the objects using Identity operators.

`Practice these in your Python IDLE.a=10b=10print(a is b) x=Truey=Trueprint(x is not y) `

## Membership Operators

Membership operators are used to test whether a sequence is presented in an object or not.

`Practice these in your Python IDLE.a = ["Python", "Awesome"]print("Python" in a)print("Python" not in a)`

## Bitwise Operators

You can use bitwise operators to compare binary numbers.

`Practice these in your Python IDLE.a = 4b = 5print(a & b)     ==> 4print(a | b)  ==> 5print(a ^ b)  ==> 1`

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.