0
How this code works? [Python]
x = 5 print(x << 2) output: 20
8 Answers
+ 5
That's binary left shift operator(<<) in python which shifts the number to the left by certain number of bits given to it's right, there is also an right shift operator(>>)
https://stackoverflow.com/questions/3411749/operator-in-python
#check this site for a list of all operators
https://www.tutorialspoint.com/python/python_basic_operators.htm
#bitwise operations python
https://wiki.python.org/moin/BitwiseOperators
+ 3
đA Z M Mushfiqur Rahmanđ is kidding. (-;
Koushik Naskar and Oma say the same (-:
+ 2
It's a series of 5,10,20,40,80,160.....of x = 0,1,2,3,4,5,6,....
0
Thats a binary left shift operator where the left operand value is moved left by digits specified by the right operand
5 in binary 101
Now move left by two place i.e. 10100 = 20
0
I'm confused.đ
0
MH Fahim whats your confusion here?
0
Koushik Naskar Now i understand bro đ
Thanks for helping.