5th Jul 2019, 4:22 PM
ANJALI SAHU
11 Réponses
+ 7
Please read this, it should contain what you need in order to understand this. https://www.sololearn.com/learn/4070/?ref=app
5th Jul 2019, 4:42 PM
HonFu
HonFu - avatar
+ 9
The binary pattern of 5 is 00000101. If you shift this two steps to the left, it becomes 00010100. And that is 20. If this is not clear to you, you should read the material here on Sololearn about how binary numbers and operators work.
5th Jul 2019, 4:26 PM
HonFu
HonFu - avatar
+ 9
Thanks everyone! I didn't knew that! 🐟
7th Jul 2019, 8:07 AM
Mr.Fish
Mr.Fish - avatar
+ 6
If we do x=5 print(x>>2) OUTPUT IS : 1 why????
5th Jul 2019, 4:28 PM
ANJALI SAHU
+ 5
00000101 shifted to the right once becomes 00000010. The right side 1 drops out.
5th Jul 2019, 4:30 PM
HonFu
HonFu - avatar
+ 4
What is the use of <<???
5th Jul 2019, 4:27 PM
ANJALI SAHU
+ 4
But this is a binary of 2???
5th Jul 2019, 4:31 PM
ANJALI SAHU
+ 4
Anhjje then answer should be 25 not 20....
5th Jul 2019, 4:36 PM
ANJALI SAHU
+ 4
Thanks everyone🙂🙂🙂
6th Jul 2019, 5:58 AM
ANJALI SAHU
+ 4
Returns x with the bits shifted to the left by y places (and new bits on the right-hand-side are zeros). This is the same as multiplying xby 2**y. IN YOUR QUESTION X=5 PRINT(x<<2) So,it will multiply 5 with 2^2 That equals ..5 *4=20 Hope it helps.. HAPPY CODING😀😀
6th Jul 2019, 6:39 PM
Dheeraj
Dheeraj - avatar
- 1
python is a general purpose, object oriented, high level programming language
7th Jul 2019, 5:31 PM
আবু বকর সিদ্দিক
আবু বকর সিদ্দিক - avatar