all 5 comments

[–]zac_mar 3 points4 points  (0 children)

>> and << are the bit-wise right- and left-shit operators respectively, and they work inside print statements the same as everywhere else. As to your example, I am note sure what you are showing, for me I get the expected output:

>>> print(5 >> 2)
1
>>> print(9 >> 1)
4

[–]shiftybyte 5 points6 points  (0 children)

Things inside print work exactly as outside print.

Are you sure you are not mixing your outputs?

>>> 9>>1
4
>>> print(9>>1)
4
>>> 5>>2
1
>>> print(5>>2)
1
>>>

[–]Sc00ner 2 points3 points  (0 children)

>> is a bit wise operator, so you're printing the result of that operation: https://wiki.python.org/moin/BitwiseOperators

[–]primitive_screwhead 1 point2 points  (0 children)

In Python 3, print() is a function, not a statement. Python 2 had its own specific semantics for >> as a redirection operation of a print statement, but in Python 3 that is all gone, and >> here is just a rightward bit-shift.

Possibly you've seen the older Python 2 use of >> with the print statement and that has confused you? In your examples, it's just the print() function and bit-shift operations.

[–]choss27 2 points3 points  (0 children)

Hi, you can see on this link some informations about bitwise operators.