Boolean:Control flow (Not operator)

Hi,
I have a hard time understanding what this means in an python code. In the lesson “CONTROL FLOW
Boolean Operators: not” there is an answer that combines “and” & “not” together. I don’t get what it really does. Can someone please explain it to me as simple as possible? Thank you.

Hi, welcome to the forums!

not negates what’s in the parentheses in the if statements in the function.

ex:
If the gpa is >= 2.0 and your credits are not >= 120, then ‘you don’t have enough credits to graduate.’
You’re comparing both sides and returning something in the output.

Boolean expressions are either True or False. You can add operators–and, or, not to make larger boolean expressions. When you have an operator, you’re evaluating both sides of the expression. But, it all goes back to two basic things: any “and” expression that has a False in it is False. Any 'or" expression that has a True in it is True.

True and False. >>>>False
True and True. >>> True
True or False >>> True

Try it in your terminal window.

not True and False
False
>>> not False or True
True
>>> 

Let me know if that helps!

2 Likes