# Boolean Order of Operations

#1

True AND NOT (False OR False) = True

• so does this mean that any time you have True AND False it equals True? I would think that it equals False because you only have a True or a False, not both. Can someone help me understand the logic?

Similarly, False OR False appears to equal False. I don’t understand this either, because there is a false and I would think that this would satisfy the OR.

#2

`True and False` will evaluate to False (equals False as you put it)

yes, it does.

What do you mean by this? In the end, all conditions have two possible outcomes:
True
False

that is it. `False or False` is False, how could this ever become True? Both are false, so the final result must be False as well

Can you now solve this equation:

``````True AND NOT (False OR False) = True
``````

?

#3

The priority is: parentheses>not>and>or.
So python first examines: False OR False the answer is False
then NOT (False OR False) => NOT False so the answer here is True
then True AND NOT (False OR False) => True AND (NOT False) => True AND True =>True
Therefore the final answer is True

The priority is important and needs to be kept in mind~

#4

Yes, I got the same result. I was thinking about this the wrong way. My last question is: why does True AND False = False?

#5

because `and` needs both condition to be true. `or` requires one of the condition to be true

which is quit useful, we need a way to check both conditions are fulfilled. This can happen. Then we use `and`.

lets do an example with `and` to prove my point:

``````feedback = raw_input("did you enjoy this course? (y/n): ")
while feedback != 'n' and feedback != 'y':
feedback = raw_input("please enter y or n: ")
``````

this is a confusing concept at first, but it can come in handy.

#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.