0

Can someone explain this question acc operator ranks and why its answer is what it is!

x=4 y=2 if not 1+1 == y OR x==4 and 7==8: Print("yes") elif x>y: Print("No")

13th Apr 2020, 5:02 PM
Tanu
5 Respostas
+ 1
When the condition evaluates to False the code block nested into condition is skipped
13th Apr 2020, 5:59 PM
Stephan
Stephan - avatar
+ 1
if not True or True and False if False or True and False if False or False False not>and>or
13th Apr 2020, 5:12 PM
durian
durian - avatar
+ 1
There is the analogy. OR is logical addition, AND is logical multiplication. So as in algebra there multiplication (AND) goes before addition(OR). Let's evaluate this condition NOT(1+1 == y) OR (x==4 AND 7==8) We could replace truly expressions with ones, falsy with zero NOT(1) + 1 * 0 NOT just inverts value from 1 to 0 and vice versa 0 + 1*0=0 So result is 0(False)
13th Apr 2020, 5:12 PM
Stephan
Stephan - avatar
0
So 3rd line's condition is False but there is no condition in it , that's like False: Print (" yes") How is its answer No?
13th Apr 2020, 5:56 PM
Tanu
0
aaah thankyou so much stephen and Lily!!!!
13th Apr 2020, 7:18 PM
Tanu