+ 1
why the answer comes yes??
x=True y= False z=False if x or y and z: print("yes") else: print("no!") here is code why it comes ?
2 ответов
+ 2
Because of the precedence of operators.
Operator and has higher precedence, it is evaluated first.
Both y and z are false, so false is returned. Then or is evaluated, and or will return true if at least one of the expressions is true. As long as x is true you will get true.
+ 15
x or y and z => true or false and false
=> true or false
=> true
so the condition of " if " statement is ture
hence it will print yes