Please, help me understand this: print(not(2==3 or 2==3 and 2==3)) ==>True print(not(2==2 or 2==2 and 2==3)) ==>False should I operate 'and ' before 'or'? or simply operate from left to right? it's spinning my head please! | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Please, help me understand this: print(not(2==3 or 2==3 and 2==3)) ==>True print(not(2==2 or 2==2 and 2==3)) ==>False should I operate 'and ' before 'or'? or simply operate from left to right? it's spinning my head please!

Confused on Precedence Operation.

27th Aug 2016, 3:07 PM
Soliu
5 Réponses
+ 11
Step1=(2==3 and 2==3) =(false and false)=false Step2=(2==3 or false)=(false or false) =false Step3=(not false)=true Step1= (2==2 and 2==3) =(true and false)=false Step2=(2==2 or false)=(true or false) =true Step3=(not true)=false
27th Aug 2016, 4:33 PM
shanthini R
+ 8
" And" is performed before "or" the same way multiplication is performed before addition unless brackets specify otherwise. Think of it as math.
27th Aug 2016, 3:33 PM
Doc
Doc - avatar
0
first right to left
9th Sep 2016, 2:40 PM
mohammad ataee
mohammad ataee - avatar
0
go with precedence rule...!! it's easy enough
27th Sep 2016, 11:53 AM
Pashupati Nath Singh
Pashupati Nath Singh - avatar
0
AND OR NOT
5th Nov 2016, 9:55 AM
Dinesh Devaki
Dinesh Devaki - avatar