Python Operators

Learn how Python performs operations on variables and values

📌 What are Operators?

Operators are special symbols or keywords in Python used to perform operations on values or variables.

➕ Arithmetic Operators

# Example
a = 10
b = 3
print(a + b)    # 13
print(a ** b)   # 1000

🔁 Comparison Operators

# Example
x = 5
y = 10
print(x != y)  # True
print(x < y)   # True

⚙️ Assignment Operators

# Example
n = 5
n += 3   # n = n + 3
print(n) # 8

🔐 Logical Operators

# Example
a = True
b = False
print(a and b)  # False
print(not b)    # True

🎯 Identity Operators

# Example
x = [1,2]
y = x
print(x is y)  # True

📚 Membership Operators

# Example
colors = ["red", "blue"]
print("red" in colors)  # True

💡 Bitwise Operators

# Example
a = 5  # 0101
b = 3  # 0011
print(a & b)  # 1