+ 2
Why is it?
x=5 print(x>>2) output: 1
5 odpowiedzi
+ 3
Hi my Friend , Do you have telegram ???
+ 2
yes
my telegram is Duvabi
+ 1
yes
my telegram is Duvabi
0
Returns x with the bits shifted to the right by y places
0
x = 5
5 in binary "101"
x >> 2
meaning right shifting by 2 places result "1" in binary which "1" in decimal too
let's look at another example:
x = 1
in binary "1"
x << 5
meaning shifting bits left by 5 places
results in "10000" which is "16" in decimal
another example:
x = 5 which is "101"
evaluating x << 2
we'll get "10100" which is "20" in decimal