0
Basic Python3 Code Question
I am a Pyhon3_Bignner. I don't understand this code. Please help me. x = 5 print(x>>2<<x) #answer = 32 print(x>>2) is 1, and print(x<<2) is 20. How does '>>' and '<<' work ?
4 odpowiedzi
+ 2
Thank you, Kevin!
I understand.
Thanks!!
+ 1
hirofumi yamada What do you mean?
You never changed x in your program. x = 5
If you want to modifie x use:
x >>= 2
And now x is 1
0
Thanks!
Now, I know that.
x>>2 is 5('000101') to 1('000001').
and 2<<x(=5) is 1('000001') to 32('100000').
So, answer is 32.
But, '2<<x' isn't '2<<1' ?