Last answered:

15 Apr 2020

Posted on:

14 Apr 2020

0

Boolean expressions doubt

If I write
x=3
y=5
print( x <<4 or y>>23)
Output: 48
How will be the output 48??

And print(x and y )

Output: 5 # how can be output 5?

1 answers ( 0 marked as helpful)
Instructor
Posted on:

15 Apr 2020

0
Hi Sai,  thanks for reaching out! The >> and << are what's known as bitwise operators in Python. So x<<y will return x shifted to the left with y bits. And x >> y returns x shifted to the right by y bits. If you'd like the boolean operators, they are single > or < , so (x < 4 and y>23)    Best,  Eli 

Submit an answer