Python Operators and Operands: Types of Operators in Python (Beginner-Friendly Guide)

Zeyan Rhys
Written by
Zeyan Rhys
Python Educator
Subarna Basnet
Verified by
Subarna Basnet
Technical Editor
Python Operators and Operands: Types of Operators in Python (Beginner-Friendly Guide)
May 1, 2025
5 min read

Table of Contents

Python is a very powerful and simple programming language. It is used to build websites, apps, games, software, and even artificial intelligence. One of the most important topics to understand in Python is the concept of operators and operands. These are the basic tools you use to make calculations, compare values, and do logical operations.

This article will explain Python operators and operands in a simple and beginner-friendly way. Whether you are a school student, college student, or a complete beginner, this guide will help you understand how operators work in Python.

What are Operators and Operands?

In any programming language, including Python, we use operators to perform operations (tasks). An operand is a value or variable on which the operator acts.

Example:

3 + 5

In this example:

  • + is the operator (it tells Python to add)

  • 3 and 5 are operands (they are the numbers we are adding)

  • The result is 8

Python supports different types of operators, and each type is used for a specific purpose. We will go through each type of operator with examples and explanations.

Types of Operators in Python

Python provides the following types of operators:

  1. Arithmetic Operators

  2. Relational (Comparison) Operators

  3. Assignment Operators

  4. Bitwise Operators

  5. Logical Operators

  6. Membership Operators

  7. Identity Operators

Let us now go through each one in detail.

1. Arithmetic Operators

Arithmetic operators are used to do basic math operations like addition, subtraction, multiplication, etc.

Operator Description Example Output
+ Addition 5 + 3 8
- Subtraction 10 - 2 8
* Multiplication 4 * 3 12
/ Division 8 / 2 4.0
% Modulus (Remainder) 9 % 4 1
** Exponent (Power) 2 ** 3 8
// Floor Division (no decimals) 7 // 2 3

Example:

a = 15
b = 4
print(a + b)  # 19
print(a - b)  # 11
print(a * b)  # 60
print(a / b)  # 3.75
print(a % b)  # 3
print(a ** b) # 50625
print(a // b) # 3

These operators are useful for performing calculations in all types of programs.

2. Relational (Comparison) Operators

These operators are used to compare two values. The result is either True or False.

Operator Description Example Output
== Equal to 5 == 5 True
!= Not equal to 5 != 3 True
> Greater than 7 > 2 True
< Less than 3 < 5 True
>= Greater than or equal to 4 >= 4 True
<= Less than or equal to 2 <= 3 True

Example:

a = 10
b = 20
print(a == b)  # False
print(a != b)  # True
print(a > b)   # False
print(a < b)   # True
print(a >= b)  # False
print(a <= b)  # True

These operators are used in conditions like if statements to make decisions.

3. Assignment Operators

Assignment operators are used to give a value to a variable.

Operator Description Example Meaning
= Assign value a = 5 a is now 5
+= Add and assign a += 2 a = a + 2
-= Subtract and assign a -= 1 a = a - 1
*= Multiply and assign a *= 3 a = a * 3
/= Divide and assign a /= 2 a = a / 2
%= Modulus and assign a %= 3 a = a % 3
**= Exponent and assign a **= 2 a = a ** 2
//= Floor divide and assign a //= 2 a = a // 2

Example:

a = 10
a += 5
print(a)  # 15
a -= 3
print(a)  # 12
a *= 2
print(a)  # 24
a /= 6
print(a)  # 4.0
a %= 3
print(a)  # 1.0
a **= 3
print(a)  # 1.0
a //= 2
print(a)  # 0.0

4. Bitwise Operators

Bitwise operators are used to compare numbers using their binary (0s and 1s) form.

Operator Description Example Result
& AND (1 if both bits are 1) 60 & 13 12
` ` OR (1 if any one bit is 1) `60
^ XOR (1 if only one bit is 1) 60 ^ 13 49
~ NOT (flips all bits) ~60 -61
<< Left shift 60 << 2 240
>> Right shift 60 >> 2 15

Explanation:

Let’s say a = 60 and b = 13. Their binary forms are:

  • a = 0011 1100

  • b = 0000 1101

a = 60
b = 13
print(a & b)  # 12
print(a | b)  # 61
print(a ^ b)  # 49
print(~a)     # -61
print(a << 2) # 240
print(a >> 2) # 15

5. Logical Operators

Logical operators are used to combine True or False values.

Operator Description Example Result
and True if both conditions are True 5 > 2 and 4 < 8 True
or True if at least one is True 5 > 2 or 4 > 8 True
not Opposite of the condition not(5 > 2) False

Example:

x = 10
y = 5
print(x > y and x < 20)  # True
print(x > 20 or y < 10)  # True
print(not(x == y))       # True

Logical operators are commonly used in if statements.

6. Membership Operators

These operators check if a value is part of a group (like list, tuple, string).

Operator Description Example Output
in True if value is in the sequence 5 in [1, 2, 3, 5] True
not in True if value is not in the sequence 4 not in [1, 2, 3, 5] True

Example:

nums = [1, 2, 3, 4, 5]
print(3 in nums)      # True
print(7 in nums)      # False
print(9 not in nums)  # True

7. Identity Operators

These check if two variables point to the same object in memory.

Operator Description Example Output
is True if both variables refer to same object a is b True/False
is not True if they do not refer to same object a is not b True/False

Example:

a = [1, 2, 3]
b = a
c = [1, 2, 3]

print(a is b)       # True
print(a is c)       # False
print(a is not c)   # True

Here, a and b point to the same object, but c is a new object with the same content.

Conclusion

Operators are the backbone of Python programming. They help us perform tasks from simple addition to complex logic. In this article, we learned about:

  • What operators and operands are

  • Different types of operators in Python

  • How and when to use each operator with examples

Once you understand how to use operators, you can build smarter and more powerful Python programs. Keep practicing with your own examples and try creating simple programs that use these operators.

In future lessons, we’ll explore how to use operators in real projects, conditions, loops, and functions. Python becomes easier as you practice, so don’t be afraid to try.

Zeyan Rhys
Zeyan Rhys
Python Educator

Zeyan Rhys is a Python developer and content writer at Syntax Notes, where he turns complex coding concepts into simple, beginner-friendly tutorials. He’s passionate about helping others understand Python in a way that actually clicks.