+ 2

syntax "|", what is mean ..

a = 5 | 5 b = 10 |5 print(a + b)

12th Mar 2021, 1:28 PM
Hieu Tran Thanh
Hieu Tran Thanh - avatar
3 Respuestas
+ 4
They are knows an bitwise operators that operates on bit , "|" Is OR bitwise operator that returns "0" for 0 and 0 , "1" for 0 and 1 , and "1" for 1 and "1". 5 has a binary value of "0101" and 10 has a value of "1010" , when you apply "|" on 5 and 5 , it yields a binary value of 0101 ("5" in decimal number system) . When applied on 10 and 5 , it yields 1111 ("15" In decimal) So you get 20 as a result. https://www.sololearn.com/learn/4070/?ref=app
12th Mar 2021, 1:46 PM
Abhay
Abhay - avatar
+ 1
Thanks
12th Mar 2021, 1:47 PM
Hieu Tran Thanh
Hieu Tran Thanh - avatar
0
Please help me
12th Mar 2021, 1:31 PM
Hieu Tran Thanh
Hieu Tran Thanh - avatar