Explain this code. How yes come??? | Sololearn: Learn to code for FREE!


Explain this code. How yes come???

x=2 y=1 if 1+1!=y or x==x and 7==8: print("yes") elif x>=y: print("no") output :-yes

6/12/2017 6:07:35 AM

Asif Mohd

4 Answers

New Answer


7==8? False.... (A) x==x? True.... (B) B && A... False...(C) 1+1!=y?... True...( D) D || C... True.. Thus "yes"


@debug the OR operator has a lower precedence than the AND operator, so && first before ||.


x==x(true) && 7==8(false) --- 0(False) 1+1!=y(true) or 0(false) --- True output "yes" the other statements inside the if... else block is left over even if they evaluates to true.


1+1 not equal to 1 - true -----or----- x is equal to x - true ___________________________________________________________________ True. -----and----- 7 is equal to 8 - false __________________________________________________________________ False. Hence the answer should be false. Try out in PC.