Print(10|7)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Print(10|7)?

why it is showing 15 as output can any one explain?

30th Dec 2018, 8:23 PM
NIKHIL DEVABHAKTUNI
6 Answers
+ 16
You are performing a binary or operation (|). 0b1010 (10 in binary) OR 0b0111 ( 7 in binary) ---------------------- 0b1111 (15 in binary)
30th Dec 2018, 8:27 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 5
Just leaving this lesson, so you can further study about it. https://www.sololearn.com/learn/4073/?ref=app Happy new Year!!!
1st Jan 2019, 12:04 PM
Seniru
Seniru - avatar
+ 5
Alice there are lots of lessons regarding bitwise operations. Here is the link if you like to learn. https://www.sololearn.com/learn/4070/?ref=app
1st Jan 2019, 2:31 PM
Seniru
Seniru - avatar
+ 2
Alice : | is a biteise operator, so it converts the decimal to binary format and performs bitwise OR opearation
1st Jan 2019, 2:49 AM
Newbie
Newbie - avatar
+ 1
thanks
30th Dec 2018, 8:28 PM
NIKHIL DEVABHAKTUNI
+ 1
Ohh Questions like this usually are in my python challenges :) thanks for explanation guys 🐍😁
1st Jan 2019, 5:30 AM
Edwing123
Edwing123 - avatar