5. Operators¶
5.1 Arithmetic Operators¶
//Integer dicision%Remainder (modulo)**Exponent
5.2 Bitwise Operators¶
&and|or^xor<<shift left>>shift right
not the same as logical operators
they operate on bits.
x = 0x0aimpliesxis a hexadecimal numberuse prefix
0bfor binary numbersstrings can be formatted in
hex as
print(f'(hex) x is {x:02x}, y is {y:02x}, z is {z:02x}')binary as
print(f'(bin) x is {x:08b}, y is {y:08b}, z is {z:08b}')
5.3 Comparison Operators¶
Equal:
==Not equal:
!=Less than:
<Greater than:
>Less than or equal:
<=Greater than or equal:
>=
5.4 Boolean Operators¶
and,or,not(noxorfor boolean operators)in,not in,is,is not
5.5 Operator Precedence¶
Arithmetic
Bitwise
Comarpsions
Boolean