We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Just like there is order of operations for mathematical operators, there is precedence for Python operators. AND has higher precedence than OR, so it is evaluated first.

## Write a function

You are viewing a single comment's thread. Return to all comments →

But then how does python know which one you mean: 1.y%4 AND y%100, or y%400

2.y%4, and y%100 OR y%400?

That's like saying these sentences state the same thing: 1.I will eat pie and roaches, or I will eat pasta.

2.I will eat pie, and either I will eat roaches or pasta.

Am I missing something?

Just like there is order of operations for mathematical operators, there is precedence for Python operators. AND has higher precedence than OR, so it is evaluated first.

Order of precedence: NOT > AND > OR