Python Operators
| Category | Operators |
|---|---|
| Arithmetic | + - * / // % ** |
| Comparison | == != > < >= <= |
| Logical | and or not |
| Assignment | = += -= *= /= //= **= |
| Membership | in, not in |
| Identity | is, is not |
| Bitwise | & | ^ ~ << >> |
a, b = 17, 5
print(a / b) # true division
print(a // b) # floor division
print(a % b) # remainder
print(a ** 2) # power
print(3 in [1, 2, 3], a > b and b > 10)
3.4
3
2
289
True False
== vs is
== compares values; is checks whether two names refer to the same object.Track your progress through the Python course