Bool

#1

Let’s practice with and. Assign each variable to the appropriate boolean value.

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

what am i supposed to be doing on the 3 middle bools? making them true?

#2

First off, be sure you understand that the only case where AND yields a True result is when BOTH operands are True (or truthy). All other cases are False.

``````False and False  =>  False
``````

See the table in the lesson text (I’m assuming there is one).

Expressions are a little trickier to evaluate visually (as we are expected to do in this exercise). Easiest to write them on paper and chip away at them.

Break it up into two expressions…

``````-(-(-(-2))) == -2

4 >= 16 ** 0.5
``````

We don’t need to evaluate the second expression if the first one is False.

#3

this is what ive done so far but im just confused what im supposed to be executing here

bool_one = -1 > 1 and (3+3) == 9

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

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

bool_four =

bool_five =

#4

Don’t do that. It’s letting the computer do the work your eyes and brain are supposed to be doing.

Evaluate the expression visually and write in only the outcome for each question, True, or False.

Like before, write out the two expressions separately and evaluate each one. Remember order of operations from maths? The same rules apply here, only they are called precedence (same meaning).

``````BEDMAS

Brackets
Exponents

Division          |
Multiplication    |  same operation but inverse

Subtraction       |  same operation but inverse
``````

So in this example,

``````-1 > 1 and (3+3) == 9
``````

we have,

``````-1 > 1

(3 + 3) == 9
``````

We know that negative 1 is not greater than 1, so that is False. We can stop there, but let’s go ahead and evaluate the other operand…

``````3 + 3 => 6
``````

We know that 6 does not equal to 9, so that too is False. No matter, we already solved the AND expression when we found the first False.

Let’s look at the next expression, broken into its two operands…

``````-(-(-(-2))) == -2

4 >= 16 ** 0.5
``````

From maths we know that raising a negative number to an even exponent yields a positive, and an odd exponent yields a negative. Those four negative signs at the same as `-1 ** 4`, which is `1`. So `1 * 2` yields `2`.

2 is not equal to negative 2, so that expression is False, and we can stop there. But let’s look at the second expression, anyway…

Exponents come first so, `16 ** 0.5` => 4. (4 is the square root of 16). The second expression yields True, but that does not matter since the first one was False.

#5

so in my code would i simplify the problem just like you did and that would be it? sorry im very new to this

#6

so questions 1 and 5 are done?

#7

Get out that pencil and paper and write out the expressions, as I have done above. Evaluate the first one, and if it yields True, then evaluate the second one. If it is also True, then the entire AND expression is True.

If the first expression is False, then forget the second, it won’t matter. The entire AND expression is False since it short-circuits on False.

#8

They’re not quite done, but visually evaluating them is a snap.

``````True and True    =>  True

False and False  =>  False``````

#9

okay that makes sense to me now but i still dont understand the application of this or very much of anything to do with coding/python. Should I be going elsewhere to learn because im as new to this as you can be and so far ive just been trying to understand this with no real grasp of whats going on.

#10

I asked for the code to get a better idea but its simply just a copied version of the code that was on the left. I believe my absolute 0 experience with coding has to be why im so confused right?

#11

It is not uncommon for learners to hit a wall if they’ve never seen this stuff before. It takes some thought process to digest. That is why it is so important to get out pencil and paper and work out each piece of the puzzle. Evaluate from the inside out, namely from the simplest components.

Even still, reset the exercise and do it again before proceeding or you will only hit another wall on the next exercise. Get this down or you will never find it any easier. It is at the backbone of programming so cannot be skipped over.

#12

real quick Udemy has a fairly cheap course for people trying to go from 0 to hero? so beginner to hopefully moderate understanding of python. Do you think this might be more appropriate for me

#13

Don’t look for an easier path… Make the path easier. This is the place to do that for nothing invested but your time and effort. May I take it you are young? That’s in your favor since it gives you lots of free time to work on this. Spend the time, before spending any money. Be sure you have cultivated an aptitude for programming before moving forward. Once you are done here, then you will be sufficiently prepared to walk into a classroom and have some wherewithal to work with.

#14

Im young but old enough where im off on my own and working plenty. Ive always had a huge interest in computers and being able to code has always fascinated me but I didnt want to spend all day attempting to understand concepts for people who already have some sort of knowledge in coding so I was completely willing to take a 12 dollar bullet if it meant it would give me an easier time to understanding the concepts. Im just about efficiency thats all

#15

By the way I appreciate all the help

#16

This is where to hone that efficiency. It won’t be simpler in a paid course, and more often than not, it will be harder, and faster paced so easier to fall behind.

#17

Just to review, as a young adult you have completed high school maths?

#18

The course said it was for absolute beginners. The price and everything else meant nothing to me if i could learn from the very beginning thats all. It feels like to me ive missed alot of the very initial steps to coding but what do i know lol

#19

Just to review, as a young adult you have completed high school maths?

yes i have

#20

So the concept of precedence is not new to you (order of operations)?

Take a moment to search out a good page on Python operator precedence. We can use that table to go forward, especially in the upcoming lessons on this subject (AND, OR, NOT).

Consider while you are doing this the nature of the conditional in,

``````if A and B:

while A and B:
``````

Also, write out this table…

``````T and T  => T

T and F  => F

F and T  => F

F and F  => F``````