Boolean syntax error

Use boolean expressions as appropriate on the lines below!

Make me false!

bool_one = (2 <= 2) and “Alpha” == “Bravo” # We did this one for you!

Make me true!

bool_two = 10 * 10 == 100 and “dog” == “dog”

Make me false!

bool_three = 100 / 10 == 9 or 40 / 10 == 3

Make me true!

bool_four = 100 / 10 == 9 not 40 / 10 == 3

Make me true!

bool_five = 100/10 == 10 or 9 * 5 == 30

Can someone help explain why I have a syntax error on bool_4?

You have put two different statements, returning two different values without logical operator in between.
If you want to find out the error - take the statement apart and analyze each part separately.
Or click the spoilers below…

Click to see the solution

So your code reads:
bool_four = 100 / 10 == 9 not 40 / 10 == 3
let’s take it apart bool_four equals:
10 == 9 returns False
not changes wathever follows to the opposite
40/10 == 3 returns False
so what you wrote, basically translates to:
bool_four = False not False
which in turn means bool_four = False True
You would need an and or an or logical operator in between these values, for the statement to be valid. And in this case specifically an or operator to complete the task.
The correct code reads:
bool_four = 100 / 10 == 9 or not 40 / 10 == 3

1 Like

Much appreciated, explanation was very helpful!

1 Like

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