Operators are special symbols in Python that carry out arithmetic or logical computations. The value that the operator operates on is called the operand.
2+3 = 5. Here,
+ is the operator that performs addition.
There are many operators in Python, some of them are:
However, in this shot, we will only be talking about the compound assignment operator and the identity operator.
The compound assignment operator performs the operation of the binary operator on both operands, and stores the result of that operation in the left operand (must be a modifiable value).
a = 10 #compound operator a += 10 print(a)
The above expression is equivalent to
a = a+10.
In the same way, we can subtract, multiply, and divide a number.
The identity operator is used to compare objects
||Returns true if both the variables are the same object.|
||Returns true if both the objects are not the same object.|
# Example on Identity operator: x = 10 y = 101 z = x is y v = x is not y print(z) print(v)
False because x is not the same object as y.
True because x is not the same object as y.
View all Courses