Python: Conditionals and Control Flow 9/15


#1

Hello i ran into this a bit earlier than this lesson when Boolean was first introduced. Im not really having a problem per say more just curious why the code below does not work in the exercise.

bool_one = 0 or not 1 and 1

bool_two = 0 and not 1 or 1

bool_three = 1 and not (0 or 0)

bool_four = not not 1 or 0 and not 1

bool_five = 0 or not (1 and 1)

The error i recieve tells me to look at “bool_two”. I change the 0 to False and the 1’s to True and it lets me advance but i only touch the code for bool_two. So my question is why does it let me proceed with all of the other bool_#'s having 1’s and 0’s but specifically not bool_two.


#2

Could it be the answers you give are not what is expected or asked for?


#3

i suppose that’s the only answer just weird that it teaches you that True and False can be represented as 1 and 0 but not accept it. ah well


#4

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

It does not accept that you provided the wrong answer. These problems are meant to be solved visually, without the aid of the computer. What you’ve done is let the computer solve the question for you. Why should it be accepted?


#5

You come off kind of harsh hah.
i wasn’t aware the answer i gave was incorrect when a few lessons ago it explains that True and False can be represented as 1 and 0
the default code on the page for the lesson looks like this.

bool_one =

bool_two =

bool_three =

bool_four =

bool_five =

It just states to assign true of false to each as i did just with 1 and 0.
Im not to sure how using 1 and 0 force the computer to work any differently than using True or False.
I think the answer i gave should be accepted because well, it accepts the other 4 variables using 1 and 0.

If the computer reads 1 and True as True and 0 and False as False; How did i let the computer solve it for me?


#6

But mean well. If you want to get something from these courses then stay the course and follow instructions. There’s plenty of time ahead to explore other avenues.

Which part of True or False is confusing in that instruction? The most successful learners here are the ones who don’t put their own spin on lessons and expect it to be accepted. Give what is asked for and you’ll find the path very straight.

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)

Do this without substituting 1 and 0 and in your head, not on the computer. The lot of these exercises are meant to be done in this fashion. Take the time to benefit from the practice.

Take the first one, for starters. What would be the first step in visually evaluating the expression?

False or not True and True
  • left to right?
  • or?
  • and?
  • not?

#7

not? correct? followed by and then or?

gotcha

not confusing at all lol i was just trying to use what was taught in a previous lesson but will follow instruction strictly from here on out thanks


#8

Correct. Order of precedence dictates, brackets, not, and, & or, in that order.


#9

A post was split to a new topic: Is “The Big If” is bugged?


#15