0

Python Code Output: Why is the answer 32?

Input: x = 5 print(x>>2<<x) Output: 32

7th May 2018, 6:19 PM
stephanie
stephanie - avatar
5 Answers
+ 3
Nope. x>>2 means binary representation x shifted twice on the right, ie x/(2^2). which equals one 1 <<5 means 1 shifted 5 times on the left, ie 2^5
7th May 2018, 6:50 PM
VcC
VcC - avatar
0
5-2=3 5-3=2 >> and << is binary сдвиг :D
7th May 2018, 6:31 PM
amchancy
amchancy - avatar
0
Thank you!
7th May 2018, 6:34 PM
stephanie
stephanie - avatar
0
I'm glad to help ;)
7th May 2018, 6:35 PM
amchancy
amchancy - avatar
0
Ah ok I got it now. Thank you!
7th May 2018, 6:59 PM
stephanie
stephanie - avatar