0

Precedence of Logical operators.

What are the precedence of these logical operators( &&, ||, !, and, or, not) from lowest to highest order in Ruby and Python ?

9th Apr 2020, 8:04 AM
Anurag Mondal
Anurag Mondal - avatar
3 Answers
+ 4
Go here and scroll down to 'Operator precedence'. https://docs.python.org/3/reference/expressions.html
9th Apr 2020, 8:15 AM
HonFu
HonFu - avatar
+ 2
Like if there is a situation like this : if cond1 && cond2 or cond3 || cond4 and cond5: In this situation how will be the conditions checked? Will cond4 and cond5 be checker first ?...or ...cond1 && cond2 ..?
9th Apr 2020, 1:35 PM
Anurag Mondal
Anurag Mondal - avatar
+ 1
HonFu I checked it out, didn't get my answer completely... I wanted to know the precedence difference of the keywords( and, or, not) and the operators(&&, ||, !) as well if used in combination..but in their precedence table they only mentioned about the keywords.
9th Apr 2020, 1:30 PM
Anurag Mondal
Anurag Mondal - avatar