Why is this True? Boolean, Python #9


#1

https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/this-and-that-or-this-but-not-that

It keeps saying that “False and not True or True” is TRUE, but by logic it seems false, and I’m not sure what I’m missing.

“Set bool_two equal to the result of ‘False and not True or True’”

This is how I see it:

False and not True or True
becomes: False and False or True
becomes: False and True
Which leads to False

But the correct answer that lets it run is:

bool_one = False
bool_two = True
bool_three = True
bool_four = True
bool_five = False

What am I missing?


#2

Hi @ajaxplayer93922,

Consider the order of evaluation …

  • not is evaluated first;
  • and is evaluated next;
  • or is evaluated last.

We got to this step successfully …

False and False or True

Now apply the and, and we have this …

False or True

Then onto the final value, as we apply the or

True

#3

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