+ 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 ?

2nd Jun 2017, 4:36 AM
venugopal
venugopal - avatar
2 Respuestas
+ 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.
2nd Jun 2017, 4:58 AM
Lana
Lana - avatar
+ 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
2nd Jun 2017, 4:55 AM
Mohammad Dakdouk
Mohammad Dakdouk - avatar