0
What does' >> 'mean in python?
7 Respostas
+ 5
If you wonder about it apearing on Terminal
It's NOTHING...
It's just the way Python console appears.. Where you can execute small python codes, line by line..
.
It's like
username-pc:$ for Linux Terminal
root@user:# for Root terminal
C:\ for windows command prompt
----
If it's used as an OPERATOR..
It's the right-shift operator of Bitwise.
print(5>>2)
Output : 1
--how?----
5 = 101 (in binary)
The statement will shift 101 right by 2 bits..
1 0 1
_\-\-\ shifted right by one bit
0 1 0
_\-\-\ again
0 0 1
+ 1
'nothing' is not true. To understand this you'll have to learn how a computer stores numbers.
try:
print( 8 >> 1) # Result will be 4
or:
print( 8 << 1) # Result will be 16
In the first example the bits of number 8 (1000 in binary) will be shifted to the right by 1 position which results in 4 (100).
The second example will shift the bits of 8 to the left by 1. The result is 16 (10000).
So shifting to the right by 1 is similar to dividing by 2, and shifting to the left by 1 is same as multiplying by 2.
Hope that helps
+ 1
This is bitwise right shift operator which works with binary form of a number and in interpreter it also indicates that u can start program.
0
You can say we are starting program from here. This is nothing but similar to $ or #symbol in Linux
0
It means u r in console mode or we can say interactive mode.in this mode it wil provide u output instantly for each code u type
- 2
Nothing at all
- 3
NOTHING!!!!!!!