Table of contents
1.
Types of Operators in Python
1.1.
1. Arithmetic Operators in Python
1.2.
Python
1.3.
2. Comparison Operators in Python
1.4.
Python
1.5.
3. Logical Operators in Python
1.6.
Python
1.7.
4. Bitwise Operators in Python
1.8.
Python
1.9.
5. Assignment Operators in Python
1.10.
Python
1.11.
6. Identity Operators in Python
1.12.
Python
1.13.
7. Membership Operators in Python
1.14.
Python
2.
Frequently Asked Questions
2.1.
What are special operators in Python?
2.2.
When an expression contains two or more operators, then in what order are the operators evaluated?
2.3.
How do operators behave with different data types?
2.4.
What is the use of operators in Python?
3.
Conclusion
Last Updated: Aug 19, 2025
Easy

Python Operators

Author APURV RATHORE
0 upvote

Python is a programming language that is quite popular and widely used around the world. It is widely regarded as the best programming language to learn first due to its ease of use. It's a popular programming language for building scalable online applications since it's quick to learn, easy to use, and deploy. Python is used to create YouTube, Instagram, Pinterest, etc.

Python Operators

Python is an excellent starting point for beginners, especially for those who prefer focusing on logic over complex syntax. To master the language, it’s essential to understand the various operators in Python.

 

Types of Operators in Python

Operators in Python are special types of symbols that perform some operation on variables. The operands are the variables on which the operator operates.

There are 7 types of operators in Python

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

We will see the above operators one by one. 

1. Arithmetic Operators in Python

Arithmetic operators are used to perform different mathematical operations such as addition, multiplication, division, subtraction, etc.

OperatorMeaningSyntax
+Adds two symbolsa + b 
-Subtracts two operanda - b 
*Multiplies two operanda * b
/Divides two operanda / b
//Divides two operands, then takes their floor valuea // b
%Finds the remainder, then the left operand is divided by the right operanda % b
**Finds the left operand raised to the power of right operanda ** b

 

Example:

  • Python

Python

x = 3
y = 9

# addition operator
print(x + y)

# subtraction operator
print(x - y)

# division operator
print(x / y)

# floor division operator
print(x // y)

# multiplication operator
print(x * y)

# modulo operator
print(x % y)

# power operator
print(x ** y)
You can also try this code with Online Python Compiler
Run Code

Output:

12
-6
0.3333333333333333
0
27
3
19683

2. Comparison Operators in Python

They are used to compare the value of the operands. They return either True or False based on the condition and the value of the operands. 

OperatorMeaningSyntax
>Greater than operator- True if the left operand is greater than the righta>b
<Less than - True if the value of the left operand is less than the value of the right operanda<b
==Equal to - True if both operands are equala==b
!=Not equal to - True if operands are not equala!=b
>=Greater than or equal to - True if the left operand is greater than or equal to the righta>=b
<=Less than or equal to - True if the left operand is less than or equal to the righta<=b

 

  • Python

Python

x = 3
y = 9

# less than operator
print(x < y)

# greater than operator
print(x > y)

# equals to operator
print(x == y)

# not equals to operator
print(x != y)

# greater than or equal to operator
print(x >= y)

# less than or equal to operator
print(x <= y)
You can also try this code with Online Python Compiler
Run Code

Output:

True
False
False
True
False
True

3. Logical Operators in Python

Logical operators are used to combine two conditional statements.

OperatorMeaningSyntax
andLogical AND: returns True if both the operands are truea and b
orLogical OR: returns True if either of the operands is true a or b
notLogical NOT: returns True if the operand is false not a

 

  • Python

Python

# and operator
print(x and y)

# or operator
print(x or y)

# not operator
print(not x)
You can also try this code with Online Python Compiler
Run Code

Output:

False
True
False

4. Bitwise Operators in Python

Bitwise operators operate on bits and perform operations bit by bit (bitwise).

OperatorMeaningSyntax
&Bitwise ANDa&b
|Bitwise ORa|b
~Bitwise NOTa~b
^Bitwise XORa^b
>>Bitwise right shifta>>b
<<Bitwise left shifta<<b

 

  • Python

Python

x = 3
y = 9

# bitwise and operator
print(x & y)

# bitwise or operator
print(x | y)

# bitwise not operator
print(~ x)

# bitwise xor operator
print(x ^ y)

# bitwise right shift operator
print(x >> y)

# bitwise left shift operator
print(x << y)
You can also try this code with Online Python Compiler
Run Code

Output:

1
11
-4
10
0
1536

You can try it on online python compiler.

5. Assignment Operators in Python

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

OperatorMeaningSyntax
=It assigns the value of the expression on RHS to the left operanda=b*c
+=Add the value of the expression on RHS to the left operanda+=b 
-=Subtract the value of the expression on RHS to the left operanda-=b
*=Multiply the value of the expression on RHS with the left operanda*=b
/=Divide value of the expression on RHS with the left operanda/=b
%=Take the modulo of right operand with the the left operand and assign the result to the left operanda%=b
//=Floor divide value of the expression on RHS with the left operanda//=b
**=Take power value using operand and assign the result to left operanda**=b
&=Take bitwise AND value using operand and assign the result to left operanda&=b
|=Take bitwise OR value using operand and assign the result to the left operanda|=b
^=Take bitwise XOR value using operand and assign the result to the left operanda^=b
>>=Calculate right shift using operands and assign the result to the left operanda>>=b
<<=Calculate left shift using operands and assign the result to the The floorleft operanda<<=b

 

  • Python

Python

x = 3
y = 9

x += y
print(x)

x = 3
y = 9

x *= y
print(x)

x = 3
y = 9

x |= y
print(x)
You can also try this code with Online Python Compiler
Run Code

Output:

12
27
11

6. Identity Operators in Python

Identity operators are a special type of operator present in Python. They are of two kinds: "is" and "it not". They check if two values are located on the same part of memory. 

OperatorMeaning
isReturns True if the operators are identical
is notReturns True if the operators are not identical

 

  • Python

Python

x = 3
y = 9

print(x is y)
print(x is x)

print(x is not y)
print(x is not x)
You can also try this code with Online Python Compiler
Run Code

Output:

False
True
True
False

Must Read Python List Operations

7. Membership Operators in Python

Membership operators are a special type of operator present in Python. They are of two kinds: “in” and “not in”. They are used to check if a value is present in a sequence. 

OperatorMeaning
inWill return True if the value is present in the sequence
not inWill return True if the value is not present in the sequence

 

  • Python

Python

x = 3
y = [1,2,3,4]

print(x in y)
print(x not in y)
You can also try this code with Online Python Compiler
Run Code

Output:

True
False

 

Frequently Asked Questions

What are special operators in Python?

Special operators in Python include identity operators (is and is not) used to compare object identities, membership operators (in and not in) used to test membership in sequences, and assignment operators (+=, -=, etc.) used for shorthand assignment operations.

When an expression contains two or more operators, then in what order are the operators evaluated?

The order of evaluations of operators is based on precedence and associativity of operators. Operator precedence determines the priorities of the operators. If two or more operators with the same precedence are present, then the order is determined by associativity. 

How do operators behave with different data types?

Operators in Python behave differently based on the data types they're applied to. For example, the addition operator (+) performs arithmetic addition with numbers, concatenation with strings, and concatenation or merging with lists.

What is the use of operators in Python?

Operators in Python are used to perform operations on variables and values. They include arithmetic operators for mathematical calculations, comparison operators to compare values, logical operators for logical operations, and more, facilitating various tasks in Python programming.

Conclusion

In this blog, we understood Python Operators. Python operators are powerful tools that facilitate a wide range of operations in Python programming. From arithmetic and comparison operations to logical and special operations, operators offer flexibility and efficiency in manipulating data and controlling program flow.

Recommended Readings:

Live masterclass