4_Operators
4_Operators
Learning objective
• Arithmetic Operators
• Relational Operators
• Assignment Operators
• Bitwise Operators
• Logical Operators
• Membership Operators
• Identity Operators
Operators
• Operators are special symbols in Python that carry out arithmetic
or logical computation.
+, -, *, /, %, **, //
Relational Operators
• Relational operators are symbols that perform operations on data
and return a result as true or false depending on the comparison
conditions.
x = [10,15,30] x = [10,15,30]
y=x y=x
z = [10,15,30] z = [10,15,30]
print(x is y) print(x is not y)
print(x is z) print(x is not z)
x = [10,20,30]
y = [10,20,30]
print(x == y) # same values
print(x is y) # different objects
print("Memory address x:", id(x))
print("Memory address y:", id(y))
You have Learnt:
• Arithmetic Operators
• Relational Operators
• Assignment Operators
• Bitwise Operators
• Logical Operators
• Membership Operators
• Identity Operators