+ 1

Can somebody please explain this python challenge question to me?

a= 5|5 b= 10|5 print (a+b) the answer to this was 20, but I don't understand why. I've never seen this kind of assignment before, and I can't find any reference to it online

9th Mar 2018, 1:41 AM
Jack Manhardt
Jack Manhardt - avatar
2 Answers
+ 5
That's bitwise or. In this context , it converts the numbers to binary takes 1 where ever possible and prints the decimal form of resulting binary number. See the answer in this link for better understanding : https://stackoverflow.com/questions/5988665/pipe-character-in-JUMP_LINK__&&__python__&&__JUMP_LINK
9th Mar 2018, 3:26 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 1
thank you! I'm familiar with bitwise operations, but did not know the syntax
9th Mar 2018, 3:29 AM
Jack Manhardt
Jack Manhardt - avatar