This and That (or This, But Not That!)


#1


https://www.codecademy.com/en/courses/python-beginner-BxUFN/2/5?curriculum_id=4f89dab3d788890003000096#

* Oops, try again. Make sure you have a value for all 5 variables!
* double cheack bool_2!

please help me. i can't understand what's wrong. i think there's some bug or it's broken. may be i am doing it wrong. please help me out.

l_one = 3==5 is False or not True and True

bool_two = 3 * 1 == 3 ** 1 is False and not True or True

bool_three = 4 == 4 is True and not (False or False)

bool_four = 3 == 6 is not (not True) or False and not True

bool_five = 4 == 4 is False or not (True and True)


#2

i think you misunderstood the exercise, for example for bool_one you have to manually evaluate this condition:

False or not True and True

depending on whether this condition is true or false, you need to set bool_one accordingly:

# set bool_one to true when condition is true:
bool_one = True
# otherwise, the condition is false so set bool_one to false:
bool_one = False

#3

but it didn't work either


#4

you misspelled bool_one, the first letter is missing


#5

thanks :3. but what's wrong with bool_4


#6

bool_four is true? the condition:

not not True or false and not True

first we have to evaluate all not's:

True or False and False

then we have to evaluate and:

True or False

True or False is True, you set bool_four to False


#7

Instructions
Assign True or False as appropriate for bool_one through bool_five.

Set bool_one equal to the result of False or not True and True
Set bool_two equal to the result of False and not True or True
Set bool_three equal to the result of True and not (False or False)
Set bool_four equal to the result of not not True or False and not True
Set bool_five equal to the result of False or not (True and True)

it becomes true and false at last not true or false. thus it's true


#8

true and false is false, but it becomes true or false at the end, which is true. See the information in the exercise:

Boolean operators aren't just evaluated from left to right. Just like with arithmetic operators, there's an order of operations for boolean operators:

  1. not is evaluated first;
  2. and is evaluated next;
  3. or is evaluated last.

#9

oh i understand now. thank you very much :slight_smile:


#10