r/learnpython • • Sep 12 '26

Are these two boolean expressions equivalent in python?

Hi All!

I’m learning about Boolean operators in Python and I’m confused about these two expressions:

condition1 and condition2 or condition3 and condition4

≠

(condition1 and condition2) or (conditon3 and condition4)

I was told this by my teacher and he put this in his PowerPoint slide. However, I think they are equivalent since and as an operator has a higher precedence than or as an operator. AI told me and I have searched it up after.

Am I understanding it correctly? Or are these two not equivalent?

Thanks!

15 Upvotes

49 comments sorted by

View all comments

Show parent comment

0

u/audionerd1 Sep 12 '26

I may have exaggerated slightly. But generally AI is more helpful because it has all of StackOverflow in it's training data and is conditioned to be polite and helpful, lol.

0

u/FunElk9586 Sep 13 '26

Yeah, I was just using AI to explain the powerpoint slides more clearly and it noted the mistake my teacher made. That is how I found out. So I guess it really is helpful😊