3 Operators
3 Operators
➢ Arithmetic operators.
➢ Comparison operators.
➢ Logical operators.
➢ Bitwise operators.
➢ Assignment operators.
➢ Membership operators.
➢ Identity operators.
Arithmetic operators:
Assignment = a=b Give b value of a
Addition + a+b Add a value to b value
Subtraction - a -b Subtract a value from b value
Unary plus + +a Multiply a value by the factor +
Unary minus - -a Multiply a value by the factor -
Multiplication * a*b Multiply a value by b value
Exponent ** a ** b a power b
Division / a/b Divide a value by b value
Floor divide // a // b Divide value a by value b and
return the nearest integer.
Modulo % a%b To get the last digit that
remains when we divide
value a by value b
Logical operators:
Logical AND and a and b Are a value and b value equal True?
Logical OR or a or b Is the value of a or b or both equal True?
Logical NOT not not a Is the value a not worth it True?
Membership operators:
IN in a in arr Is the value of the variable a present in the array arr?
NOT IN not in a not in arr Is the variable value a not present in the array arr?
Identity operators:
IS is a is b Do object a and object b refer to the same object in
memory?
IS NOT is not a is not b Do object a and object b not refer to the same object
in memory?