+ 1
Iâm extremely confused, please do answer in detail..
x=4 y=2 if not 1+1==y or x==4 and 7==8 print(âYesâ) elif x>y print(âNoâ) ⢠Yes ⢠No ⢠Yes No
6 Answers
+ 6
In:
not 1+1==2 or 4==4 and 7==8
+ operations have the highest operation precedence, thus + operations are evaluated first:
1+1 ---> 2
We get:
not 2==2 or 4==4 and 7==8
Where the comparison operators have the highest operation precedence, let's evaluate the comparison operations:
2==2 ---> True
4==4 ---> True
7==8 ---> False
We get:
not True or True and False
Where not has the highest precedence:
not True ---> False
We get:
False or True and False
Where and has the highest operation precedence:
True and False ---> False
We get:
False or False ---> False
+ 3
You can use braces to clarify your doubts, they would make the single conditions a bit better readable and understandable. Then you'll see, that the conditions for // edit see other post.
+ 3
Sorry, didn't read it accurate - first branch is not evaluated as true due to that "and 7==8".
+ 3
ya.. and when I went for the 3rd option, it said that it was wrong..
+ 3
It is, see my second post, sorry đ
+ 3
itâs ok