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

+3

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

+16

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

+4

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

+2

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.

-5

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.