5. And


#1

Confused as to what the task is, and what the and boolean itself is.
This confused me also in Java which is why I stopped it for a while.

Here's the instructions:

The boolean operator and returns True when the expressions on both sides of and are true. For instance:

1 < 2 and 2 < 3 is True;
1 < 2 and 2 > 3 is False.
Instructions
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


#2

Any help much appreciated, thanks.


#3

Hello, @thebrokencode!
You're supposed to assign each of those things to a variable.
Will you store the entire statement? No, no. You'll store the logic value of it!
Example:

x = 2 > 3 # Is two greater than three? No, it's False so that logic value, False, will be stored in the variable x

Best regards,
G4be

Edit: other example would be:

 y = True and False #True and False is equal to False so that value will be stored into y

#4

this is what i did

bool_one = False and False

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

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

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

bool_five = True and True

u welcome lol


#5

Wow... lol It took me 30min trying to figure it out...


#6

I had alot of problems with this one....the explanation is not very good. Once you get round that then its easy.Just feed an editor with -(-(-(-2))) == -2 and 4 >= 16**0.5 and the answer pops up!


#7

On this exercise the styling has to be changed so it is more clear what the logical expressions are. For an example for boolean variable four we have

Set bool_four equal to the result of -
(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

It is very easy to miss the "-", which I did and subsequently the evaluation of the expression resulted in "False" rather than "True". Wouldn't it be better if the entire expression is moved onto a new row like this?

Set bool_four equal to the result of
-(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2


#8

I entered

bool_one = False and False
bool_two = False and True
bool_three = True and False
bool_four = -(1**2) < 2**0 and 10 % 10 <= 20 - 10
bool_five = (12 / 4) == 3 and 21 <= (7 * 3)

and it was came back as correct ... though not sure why


#9

Thank you, I have been struggling with this for quite a while.


#10

I've been stuck on this for an hour. I retyped the same exact thing over and over and couldn't get it to work. Finally, I just took the lazy way and copied and pasted yours to mine and viola!


#11

I think you are meant to put the answer of True or False to each variable.

This is what I did and got Way to go!... lol

bool_one = False

bool_two = False

bool_three = False

bool_four = True

bool_five = True


#12

My gosh I was trying to say if they were both true or both false for the longest time but I just copy-pasted this and entered it haha


#14