| Operator |
Description |
** |
Exponent |
+ |
Addition |
- |
Subtration |
* |
Multiplication |
/ |
Division |
% |
Modulus |
// |
Floor Division |
- Comparison (Relational) Operators
| Operator |
Description |
< |
Less than |
> |
Greater than |
<= |
Less than or Equal to |
>= |
Greater than or Equal to |
== |
Equal to |
!= |
NOT Equal to |
| Operator |
Example. |
Equivatent to. |
= |
x = 5 |
x = 5 |
+= |
x += 5 |
x = x+5 |
-= |
x -= 5 |
x = x-5 |
*= |
x *= 5 |
x = x*5 |
/= |
x /= 5 |
x = x/5 |
%= |
x %= 5 |
x = x%5 |
**= |
x **= 5 |
x = x**5 |
//= |
x //= 5 |
x = x//5 |
| Operator |
Meaning |
and |
True if both the operands are true |
or |
True if either of the operands is true |
not |
True if operand is false (complements the operand) |
| Operator |
Meaning |
& |
Bitwise AND |
| ` |
` |
~ |
Bitwise NOT |
^ |
Bitwise XOR |
>> |
Bitwise right shift |
<< |
Bitwise left shift |
| Operator |
Meaning |
Example |
in |
True if value/variable is found in the sequence |
5 in x |
not in |
True if value/variable is not found in the sequence |
5 not in x |
| Operator |
Meaning |
Example |
is |
refer to the same object |
x is True |
is not |
do not refer to the same object |
x is not True |
if condition:
operation
elif condition:
operation
else:
operation
for i in iterables:
operation(with i or not)
condition = True
while condition:
operation