Else Problems, I Feel Bad for You, Son

#1
``````answer = "'Tis but a scratch!"

def black_knight():
if answer == "'Tis but a scratch!":
return True
else:
return 1 > 3       # Make sure this returns False

def french_soldier():
if answer == "Go away, or I shall taunt you a second time!":
return True
else:
return   1 == 3     # Make sure this returns False
``````

Why this work if I put False, but it doesn’t work if I put a statement that results False? (1 > 3) (! == 3)

#2

because the exercise expects you to use `False` keyword, using something like `1 == 3` is a terrible idea, another programmer looking at your code would be very confused by it. So codecademy only approves False keyword, given that is what you should use here

#3

I believe I understand what you have written but I’m still confused.

In exercise 8: NOT it was request to put a result True/False, (Set bool_one equal to the result of…) but the program would run correct also with the formula instead.
I’ve tried out of curiosity…

``````
bool_one = not True

bool_two = not 3**4 < 4**3

bool_three = not 10 % 3 <= 10 % 2

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

bool_five = not not False
``````

So to change my question and understand better, is it so that
"Make sure this returns False" actually means always and only “write ‘False’ here”?

Thank you

#4

i need to see the exact instructions, please share the exercise url

#5

#6

you should evaluate the conditions manually, and then set the variable according to the result (so the variable should be a boolean value), unfortunately, the validation isn’t setup perfectly.

#7

As @stetim94 mentioned, this series of exercises are all meant to be done visually. We do not really learn much if we let the computer evaluate the expressions.

``````not True
``````

This one is obvious, the opposite of True is False.

``````not 3 ** 4 < 4 ** 3
``````

To help us with this one we need a table of operator precedence…

Python Operator Precedence

The table reads from top down, in order of precedence. HIghest up the list is, `**` (exponentiation) so that operation is completed first (in our mind)

``````3 to the 4th is the same as 9 squared, or 81

4 cubed is 64
``````

So now we have,

``````not 81 < 64
``````

Next highest in the table is `<` (comparison operators), so,

``````not False
``````

and from there we get to, True.

Getting the idea?

#8

Thank you for writing.
After a couple of tentatives I’ve understood the exercise and did it correctly. I was confused only by the fact that the program runs anyway, if I solve the problem or not.

@stetim94 has clarified that it is not perfect and it’s ok. Now I understand better also my mistake in the original exercise in this topic.

This is a brand new field for me and I have at times troubles understanding the instructions and confusion accumulates, thank you both for taking your time and helping me.

#9

Let yourself be the judge, and do not be too kind. Test, test, and test again until you are truly satisfied.

#10

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