+ 1

Pls explain this question

print (12 & 20) I got 4 output why??

7th Dec 2020, 7:24 AM
Chain Sing Maravi
Chain Sing Maravi - avatar
2 Answers
+ 6
'&' symbol represent the bitwise and operation. So you have to convert 12 and 20 to binary to get the output. 12- 00001100 20- 00010100 12 & 20- 00000100 0 & 0 --->0 1 & 1 --->1 1 & 0 --->0 Then convert 00000100 to decimal. It is equal to 4.
7th Dec 2020, 8:29 AM
Yasara hasini
+ 2
https://www.sololearn.com/learn/4072/?ref=app See this I think this would help
7th Dec 2020, 7:34 AM
Piyush
Piyush - avatar