Python Operators
What Are Operators?
• Operators perform operations on variables
and values.
• Example: a + b, where '+' is the operator and
a, b are operands.
Types of Operators Covered
• Arithmetic Operators
• Assignment Operators
• Comparison Operators
• Logical Operators
Arithmetic Operators
• +: Addition (x + y)
• -: Subtraction (x - y)
• *: Multiplication (x * y)
• /: Division (x / y)
• %: Modulus (x % y)
Assignment Operators
• =: x=5
• += : x += 2 → x = x + 2
• -= : x -= 3 → x = x - 3
• *= : x *= 4 → x = x * 4
• /= : x /= 2 → x = x / 2
Comparison Operators
• == : Equal to (x == y)
• != : Not equal to (x != y)
• >: Greater than (x > y)
• <: Less than (x < y)
• >= : Greater than or equal (x >= y)
• <= : Less than or equal (x <= y)
Logical Operators
• and : True if both are true (x > 3 and x < 10)
• or : True if one is true (x > 3 or x < 4)
Summary
• Python provides various operators for efficient
programming.
• Mastering operators helps in writing clear and
effective code.
Q&A
• Any Questions?