Software Training Institute in Chennai with 100% Placements – SLA Institute
⭐ Exclusive Summer Courses Offer ⭐ 💰 Flat ₹5,000 - ₹10,000 off on all courses 👨‍👩‍👧 Additional discounts for group enrollments 🎓 100% Placement Support 🏆 90,000+ Students Successfully Placed 🚀 Avail now! Limited seats only!
Python Operators
Share on your Social Media

Python Operators

Published On: April 8, 2026

Introduction to Python Operators

When it comes to programming, variables and constants are nouns, while operators are the verbs. Operators are the special keywords or symbols used to instruct the interpreter to perform a series of mathematical or logical operations.

Whether it is calculating the trajectory of a rocket or checking whether a username is already taken, operators are the tools of choice when it comes to programming in Python. Learn what is operators in Python with our Python tutorial for beginners.

1. Arithmetic Operators in Python

Arithmetic operators are used to perform mathematical operations on numeric values. These are the most basic operators used by any programming language and are the ones most people are accustomed to since they were first introduced in elementary math.

OperatorNameDescriptionExample (a=10,b=3)
+AdditionAdds two operandsa+b=13
SubtractionSubtracts the right operand from the lefta−b=7
*MultiplicationMultiplies two operandsa∗b=30
/DivisionDivides left operand by right (results in float)a/b=3.33
%ModulusReturns the remainder of the divisiona%b=1
**ExponentiationLeft operand raised to the power of right operanda∗∗b=1000
//Floor DivisionDivision that results in a whole number (downward)a//b=3

Code Example:

x = 15

y = 4

print(f”Addition: {x + y}”)        # 19

print(f”Modulus: {x % y}”)         # 3 (15 divided by 4 leaves 3)

print(f”Floor Division: {x // y}”) # 3 (15 / 4 is 3.75, floor is 3)

2. Comparison / Relational Operators in Python

Comparison operators are used to perform comparisons between two values. The result of a comparison operation is always a Boolean value.

OperatorNameExample
==Equalx == y
!=Not equalx != y
>Greater thanx > y
<Less thanx < y
>=Greater than or equal tox >= y
<=Less than or equal tox <= y

3. Logical Operators in Python

Logical operators in Python are required to link two or more condition statements. They are extremely important for decision-making in your code.

  • and: Returns True if both statements are True.
  • or: Returns True if at least one of the statements is True.
  • not: Returns the opposite of the statement.

Code Example:

age = 25

has_license = True

# Logical AND

if age >= 18 and has_license:

    print(“You can drive.”)

# Logical NOT

is_weekend = False

if not is_weekend:

    print(“Time to go to work!”)

Practice with more real-time examples through our Python project ideas.

4. Assignment Operators in Python

Assignment operators are required to assign a value to a variable. The basic assignment operator is the equals sign (=), but Python has “augmented” assignment operators.

OperatorEquivalent to
+=x = x + 3
-=x = x – 3
*=x = x * 3
/=x = x / 3
%=x = x % 3
//=x = x // 3

5. Bitwise Operators in Python

These are operators that perform a specific action on the “bits” (the 1s and 0s) of the number.

OperatorNameDescription
&ANDSets each bit to 1 if both bits are 1
|ORSets each bit to 1 if one of two bits is 1
^XORSets each bit to 1 if only one of two bits is 1
~NOTInverts all the bits
<<Zero fill left shiftShift left by pushing zeros in from the right
>>Signed right shiftShift right by pushing copies of the leftmost bit

These operators are less commonly used in high-level web dev but are extremely important for things like cryptography and graphics.

6. Identity and Membership Operators

These operators are unique to Python and make Python a very readable language.

Identity Operators

These are used to compare two variables, not for equality but for sameness.

  • is: This returns True if the two variables are the same.
  • is not: This returns True if the two variables are not the same.

Membership Operators

These are used to compare a sequence (like a string, list, etc.) and whether it is present in an object.

  • in: This returns True if a sequence containing the specified value is present.
  • not in: This returns True if the value is not present.

Code Example:

fruits = [“apple”, “banana”, “cherry”]

print(“banana” in fruits)     # True

print(“orange” not in fruits)  # True

# Identity Example

a = [1, 2, 3]

b = [1, 2, 3]

c = a

print(a is c)     # True (c points to the same list as a)

print(a is b)     # False (they have the same content, but are different objects)

Enroll in our Python Training in Chennai for comprehensive learning.

Operator Precedence

Just as we have a specific order for mathematical calculations (PEMDAS), Python has a specific order for calculations as well. In other words, multiplication comes before addition.

  • Parentheses ()
  • Exponentiation **
  • Multiplication, Division, Floor Division, Modulus *, /, //, %
  • Addition, Subtraction +, –
  • Bitwise shifts <<, >>
  • Comparisons >, <, ==, etc.
  • Logical NOT not
  • Logical AND and
  • Logical OR or

Conclusion

As long as you can understand what are operators in Python, you can perform a wide variety of complex logic. From basic addition to determining whether a certain member is present in a list, you can use the tools provided by the Python basic operators to transform raw information into a more meaningful form.

With the help of the basic operators in Python with examples, you can control the flow of your programs and perform complex mathematical calculations without writing a lot of code. Explore more courses by visiting our software training institute in Chennai.

Share on your Social Media
Get Your Instant Job & Placement Eligibility
Report in Just 30 Seconds!
Below 30% - not Eligible (Needs Preparation)
30% – 70% - Partially Eligible (Needs Guidance)
Above 70% - Fully Eligible (Ready to Start)

We are excited to get started with you

Give us your information and we will arange for a free call (at your convenience) with one of our counsellors. You can get all your queries answered before deciding to join SLA and move your career forward.