Python bitwise shift left is done with the <<
operator. x <<
y, will shift x by y places to the left at the bit level.
>>> 38 << 2
152
As you can see below 152 is binary 38 shifted two 0s to the left
38 = 00000000 00000000 00000000 00100110
<< 2 = 00000000 00000000 00000000 01001100 = 152
Bitwise shift left can only be done with integers
>>> 38.2 << 5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for <<: 'float' and 'int'