Python Boolean Operators No. 6. And


#1

I don't get the instructions!!
Question 1. it says: Set bool_one equal to the result of False and False. Set bool_five equal to the result of True and True
do I have to write "False and False" or 1 != 1.
Question 2. it says : 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
do i have to figure out the equation?


#2

Don't forget the following when thinking in terms of booleans:

True and True == True
True and False == False
False and True == False
False and False == False
 
True or True == True
True or False == True
False or True == True
False or False == False
 
Not True == False # !(True) == False
Not False == True # !(False) == True

With those in mind, the exercise in your first question is asking you to set bool_one to the result of False and False.

The same principle applies to your second question - you need to decide whether the statement -(-(-(-2))) == -2 and 4 >= 16**0.5 is True or False, and set the value of bool_two accordingly.

They do look tricky at first sight, but if you do it one step at a time:

-2 == -2 # True
-(-2) == -2 # False, because -(-2) is the same as 2
-(-(-2)) == -2 # True, because -(-(-2)) is the same as -2
-(-(-(-2))) == -2 # False, because -(-(-(-2))) is the same as 2

4 >= 16**0.5 # True, because 16**0.5 is 4

Taking the two statements together you have a case where one is False and the other is True. In other words, bool_two should be set to the result of True and False (look in the table I provided above).

You will have to do the same for bool_three and onwards - if you have trouble with the symbols, here's a handy overview of them.


#3

thanks this helped a lot :smiley:


#4

I am having problem with bool_four:
Is this not the correct answer?:
bool_four = -1<1 and 0<=0 is True
Thank you.


#5

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