Operators in python
Python operators are special symbols or keywords used to perform operations on variables and values. They form the backbone of expressions, conditions, calculations, and logical decisions in Python programs.
Get Saurabh Gandhi’s stories in your inbox
Join Medium for free to get updates from this writer.
This article explains all types of Python operators with clear definitions, syntax, and easy examples, making it ideal for beginners and interview preparation.
What are Operators?
Operators in general are used to perform operations on values and variables. These are standard symbols used for logical and arithmetic operations. In this article, we will look into different types of Python operators.
- OPERATORS : These are the special symbols. Eg- + , * , /, etc.
- OPERAND : It is the value on which the operator is applied.
Example:
a = 10
b = 5
print(a + b)Here, + is an operator that adds two values.
Types of Operators in Python
Python supports the following major types of operators:
- Arithmetic operators
- Comparison operators
- Assignment Operators
- Logical Operators
- Bitwise Operators
- Identity Operators
- Membership Operators
1. Arithmetic operators
Python Arithmetic operators are used to perform basic mathematical operations like addition, subtraction, multiplication, and division.
2. Comparison operators
Comparison operators compare two values/variables and return a boolean result: True or False
3. Logical operators
Logical operators are used to check whether an expression is True or False. They are used in decision-making.
4. Bitwise operators
Python bitwise operators are used to perform bitwise calculations on integers. The integers are converted into binary format and then operations are performed bit by bit, hence the name bitwise operators. Python bitwise operators work on integers only and the final output is returned in the decimal format. Python bitwise operators are also called binary operators.
5. Identity Operators
Identity operators in Python are used to compare the memory locations of two objects to determine if they refer to the same object.
6. Membership Operators
Membership operators in Python are used to test whether a value or variable is a member of a sequence (such as a string, list, or tuple).
Questions
- What are operators in Python?
- How many types of operators are there in Python?
- What is the difference between
/and//operators? - What is the difference between == and is
- What are logical operators in Python?
- What are membership operators?
- What are bitwise operators used for?









