Python Operators – Quick Notes
Python operators are special symbols used to perform operations on variables and values.
Arithmetic Operators
Operator Description Example Result
+ Addition 5+3 8
- Subtraction 5-3 2
* Multiplication 5*3 15
/ Division 5/2 2.5
// Floor Division 5 // 2 2
% Modulus 5%2 1
(remainder)
** Exponentiation 2 ** 3 8
Comparison (Relational) Operators
Operator Description Example Result
== Equal to 5 == 3 False
!= Not equal to 5 != 3 True
> Greater than 5>3 True
< Less than 5<3 False
>= Greater than or 5 >= 3 True
equal
<= Less than or equal 5 <= 3 False
Assignment Operators
Operator Description Example
= Assign x=5
+= Add and assign x += 2 → x = x + 2
-= Subtract and assign x -= 2
*= Multiply and assign x *= 2
/= Divide and assign x /= 2
//= Floor divide assign x //= 2
%= Modulus and assign x %= 2
**= Exponent and assign x **= 2
Logical Operators
Operator Description Example Result
and Logical AND True and False False
or Logical OR True or False True
not Logical NOT not True False
Bitwise Operators
Operator Description Example Result
& AND 5&3 1
| OR 5|3 7
^ XOR 5^3 6
~ NOT (invert bits) ~5 -6
<< Left Shift 5 << 1 10
>> Right Shift 5 >> 1 2
Membership Operators
Operator Description Example Result
in True if value found 'a' in 'apple' True
not in True if value not 'z' not in 'apple' True
found
Identity Operators
Operator Description Example Result
is True if same object x is y True if same object
in memory
is not True if not same x is not y True if not same
object object