9/15 not outcomes dont come first?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/this-and-that-or-this-but-not-that?action=lesson_resume&link_content_target=interstitial_undefined

<In what way does your code behave incorrectly? Include ALL error messages.>
bool_four = “not not True or False and not True” = True (answer)

<What do you expect to happen instead?>

shouldnt it be False??? below is my thought process…

“not not” True (=True) or False and “not” True (=False) — “not” first —> True or False and False
True (from not’s) or False “and” False (from not) — “not” outcomes take priority then “and” —>
True and False (=False) or False — then “or” —> False or False = False (my answer, but wrong)

it seems that the “not” outcomes dont take priority, so True or False and False on the first line above would actually “and” False, False equaling False; then “or” True, False equaling True making True (actual answer). I do these in my head and do them at once, but it seems that working the “not” out seems helpful.

```python

Replace this line with your code.

<do not remove the three backticks above>

#2

we can see the evaluation order here:

http://www.informit.com/articles/article.aspx?p=459269&seqNum=11

so first not, then and and finally or

we have:

not not True or False and not True

if we then evaluate all the nots we get:

True or False and False

then and takes priority, False and False is false, so we get:

True or False

which evaluate to true

it seems you don’t prioritize and over or


#3

Hi there!

You evaluate “True or False” to False.

Yet, in the “Hint” for section 09/15 “True or False” are being evaluated to True.

I liked your explanation but your final evaluation confuses me.

Thanks for the help!


#4

you’re right, it should be evaluate to true. I am human, i can make mistakes. Nice catch, thank you :slight_smile:

The fact that you caught the mistake is the ultimate prove you understand it perfectly :slight_smile:


#5

I’m just reliefed that I have finally understood it :slight_smile:

Thanks again for your explanation; it really helped me.


#6

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