Can someone plz explain == and OR | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Can someone plz explain == and OR

It's bit tricks for me I need general level explanation for above question?

21st Oct 2018, 7:00 AM
Tejas
Tejas - avatar
7 Answers
+ 5
its about operator precedence, or which operation need to be done first. just like 2+3*2=8 in this case == is done before OR so first one fasle==false -> true. true or true -> true (check) if parentheses exist they'll be done first (false or true) -> true. false == true -> false i guess you can work on the third one now
21st Oct 2018, 7:16 AM
Taste
Taste - avatar
+ 5
== (equal to) is a comparision operator, it'll check if the left side value and right side value are equal, if it is it'll return TRUE OR is logical operator which only take a boolean (TRUE/FALSE) or equivalent as the input, it'll always return true if one of either side or both side are TRUE
21st Oct 2018, 7:06 AM
Taste
Taste - avatar
+ 2
Operator Precedence Operator precedence is a very important concept in programming. It is an extension of the mathematical idea of order of operations (multiplication being performed before addition, etc.) to include other operators, such as those in Boolean logic. The below code shows that == has a higher precedence than or:
21st Oct 2018, 7:08 AM
Tejas
Tejas - avatar
+ 1
Can u explain this
21st Oct 2018, 7:09 AM
Tejas
Tejas - avatar
0
>>> False == False or True True >>> False == (False or True) False >>> (False == False) or True True
21st Oct 2018, 7:09 AM
Tejas
Tejas - avatar
0
Thanks Taste
21st Oct 2018, 7:18 AM
Tejas
Tejas - avatar
0
I think you have god gifted logic (of course you have worked hard) But really amazing Also I have gone through profile. People like you are making out life's more simple
21st Oct 2018, 7:20 AM
Tejas
Tejas - avatar