Mix 'n' Match help please!


#1

Hello guys
I just don't understand the code, I have no idea what to do. I'm stuck on Mix 'n' Match and here is my last code which gives out an 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 = (7 > 4) or (10 < 16)

# Make me false!
bool_three = (500 == 400) not (300 > 700)

# Make me true!
bool_four = (50 != 20) and "Cyclops" == "Cyclops"

# Make me true!
bool_five = (2 * 5 == 10) or not (4 > 12)

Of course I do not completely understand what I am doing and I can't understand. Maybe someone will tell me where I can learn this topic in an easier way?
I don't understand, why the first line

Make me false!

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

Why is it false, anyway? 2 is less or equal to 2 and "Alpha" is not equal to "Bravo". So it's True and False.
But why does it make this False?
Can someone explain please, what to do, I don't want to continue without understanding this.

By the way, here's the error:

File "python", line 10
bool_three = (500 == 400) not (300 > 700)
^
SyntaxError: invalid syntax


#2

Sorry, the error copied a bit wrong. This sign "^" in my error is on the bracket before number 300


#3

Yes, you're right. It's True and False.
But what the 'and' operator does is check both sides, if BOTH sides are True, it will be True.
If it's anything else (e.g. False and True, False and False), then it will be False.

You got that error because that's not how 'not' works.
You only need one condition to use with 'not'.
So, instead of 'bool_three = (500==400) not (300>700)', you do something like 'bool_three = not (300>700)'.

But that will output True, because (300>700) is false, but when you use 'not', True becomes False and False becomes True.

So, just use a condition that will result in True, and a not in 'bool_three'.


#4

Thank you, I understand it better now. Also watched a video on YouTube and it's not that bad now.


#5

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