A little confused

Hello, I am doing the Conditionals and Control Flow, Not, “exercise”. I have come across what i believe to be a bug, but wanted to post a topic first.

Here is the exercise. https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/not?action=resume_content_item

Shouldn’t bool four be false? When i put bool four as false, it makes me put it as true in order to pass the exercise, but i’ve puzzled over it for a couple minutes and i’m almost certain it’s false. Thoughts?

its True

could you solve the comparison for me so i can see where you go wrong and help you where needed?

Of course.

not 3 ** 2 + 4 ** 2 != 5 ** 2

not 6 + 8 != 10

not 14 != 10

not True

False

that explains the problem. ** is not the multiplication operator.

go ahead and try it out:

print 3 ** 2
1 Like

Ah! It’s to the power of. What is multiplication?

oops, made an edit. * is the multiplication operator. ** is exponent

1 Like

Thank you very much. I’ll get better at this soon enough :sweat_smile:

Pardon, I don’t want to create a new topic for this question so I hope you don’t mind if i reply with another question.

https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/the-big-if?action=resume_content_item

Is there a more efficient way to do this that i’m just over-complicating, or am i not understanding the exact task?

i can’t see what you coded, it will just load my own code (it checks for logged in user)

Okay, I think i see why it prints two B’s and one A. The A is above 90 so it marks it as A, but the two B’s are below 90 but above 80. How do I fix this?

I changed all my or to and, and in the console it actually printed A, C, F, but it still says my solution is incorrect.

elif grade == (89) or grade <= 80 means if grade equals exactly 89 or is less then 80, run this elif clause.

so 81 till 88 will return F (else), and everything less or equal to 80 will return B.

you shouldn’t need or or and here, if the value is 90 or higher the if clause will run. So you don’t need to double check this add the elif clause

Okay, I see what you mean by the less or equal to thing. So how do i write in code the sentence, “If it is BETWEEN 89 to 80, make it a B”. I’m sure the solution is simple but i don’t know how to.

Oh I did it!!!

I still have my ands though. What is the solution without and?

i wouldn’t bother with it. Values equal or higher then 90 are caught by if condition. Once the if clause runs, the remaining conditions and clauses are skipped

so all you need to do is check that the value is equal or higher then 80

the grade <= 89 is redundant. Its already lesser then 90, otherwise the code execution won’t even get there

I took a day break and came back and reread your answer. Makes a lot more sense now! I don’t need the “Below 89” thing because if it was above 89 it would have already been caught by the first If! Thank you for the help! I’m sure I’ll need a lot more in the future :grinning: