"And" #4


-(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

Boolean "And" answers are either "True" or "False", correct?

Bool #4 - -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2 seems to be neither.

Any clues to solving this one?


Booleans are primitives, True or False. There is no in between.

All expressions in any form may be cast to a boolean through evaluation of the value the expression yields. Conditionals work on the premise of assertions.

a == b

is an assertion, which is stating that a is the equal of b. The interpreter looks at this and gives its evaluation. If a is not the equal of b, then the evaluation will be False. This is what the computer sees.

We see 6 * 7, the computer sees 42. It's what makes understanding expressions so confusing in the first place. We see a number of operands, the computer sees only the evaluation given it by the interpreter.

Bottom line, there can't be a case of 'neither'.

>>> -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2


Thank you, mtf. My problem is that in the "And" exercise when I assign "True" as the answer, I am still getting the error message: "Oops, try again. Double check your value for bool_four!"

Both True and False are giving the same error message. The syntax is verbatim from the presented problem.


I am still guessing as to the exercise. Are you being expected to assign the visual evaluation of the expression?

bool_four = True

... as an example to the question.


I also thought this activity was confusing, even though I got no error. Perhaps jgelis accidentally added another minus/negative sign: See where he typed
"Bool #4 -" then the negative statement after that.


jmcraig2000, I copied and pasted the problem. The interesting part is that both true and false gave me an error. I will make sure there isn't an errant "-" after bool_four. Thanks


We could still use a link to the exercise. Please post it here so we can test your code.



A gist doesn't help. We need the actual exercise page, please.


Sorry, Roy. Still trying to figure this all out. See link below. Thanks.

Link to the "And" problem in question



The responses we give should be based upon visual inspection, not computed expressions. If we cannot master analyzing expressions visually then this will be our Achilles Heel forever.

One of the best things to get a firm grip on is short-circuiting.

False and False

The above expression is not fully evaluated. The left hand operand is False, and evaluation ceases, yielding False. Visually, we take one look at this and know the value.

-(-(-(-2))) == -2 and 4 >= 16**0.5

A quick count of the negative signs tells us that the outcome is a positive number (even count is always positive outcome), not equal to -2. Again, short-circuit on False.

19 % 4 != 300 / 10 / 10 and False

This one we don't need to look at the left side. and False is always False. We can spot this in a jiffy. No short circuit, but obvious to the eye.

-(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

Visually, -1 is less than 1, move to next operand. 0 is equal to 0. Both assertions are True, so yield True.

True and True

Always True.

Simple rule of thumb:

AND  =>  always short-circuits on False

OR   =>  always short-circuits on True


Roy, not sure how this applies to the dilemma I am having here. The answer
for bool_four can either be "True" or "False". Neither one of these answers
is satisfying this stated problem.


I'm not able to reproduce this problem...

# False and False
bool_one = False
# -(-(-(-2))) == -2 and 4 >= 16**0.5
bool_two = False
# 19 % 4 != 300 / 10 / 10 and False
bool_three = False
# -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2
bool_four = True
# True and True
bool_five = True




To repeat, do not evaluate by computing the expressions. Read my previous couple of posts again.


Roy, I understand visual expression and not computing. I also understand
the Boolean choices of either “True” and “False”, with there being no other
options. With that being said, bool_4 calls for either a “True” or a
“False” response. One or the other. When I provide “False” I get an error
code. When I provide “True” I get an error code. Please tell me I am not
going crazy, because this seems like Logic 101. Am I missing something


Please post your raw code, not a gist or photo. We'll get to the bottom of this.


Yes. Examine the example I posted earlier. That is what the lesson checker expects. There is a difference between editor written code and console written output. This lesson checker is looking at the editor, not the console.


Ok Roy, I will look it over carefully. Thanks for your help.


Please do not think of me as stymying your progress. I love that you brought the operator, is into the fray, but it is not expected, and has not yet been covered in this track. I do see where you are going. That's not a problem on the whole, only in what this lesson expects. The author has tried to keep us on station. The literal evaluations written directly in our code is what is expected. Whence that requirement is upheld, we are free to explore and I hope you will!