When to use the parentheses in the boolean expression

Why are we using the parentheses in the boolean expression with ‘not’ at the end, but fail to use them in the previous expressions?

Thanks for any advice.

python has order of operations:

an order in which operators are evaluated.

given >= precedes not and and operator, the parenthesis are redundant.

If they are redundant, why would the platform be indicating an error? Are you suggesting the parentheses are unnecessary for the 3rd expression?

That is a different question entirely. I don’t know, this would require:

the exercise url and the code copy pasted to the forum, so I can replicate the error.

unnecessary, redundant, nearly the same thing.


statement_one = not (4 + 5 <= 9)

statement_two = not (8 * 2) != 20 - 4

credits = 120
gpa = 1.8

if not credits >= 120:
  print("You do not have enough credits to graduate.")
if not gpa >= 2.0:
  print("Your GPA is not high enough to graduate.")
if not (credits >=120) and not (gpa >=2.0):
  print("You do not meet either requirement to graduate!")

What error do you get? I ran your code, and everything went smoothly.

I get it if I do not use parentheses in the third function:

I should say, if I put the parentheses in then run, it works fine. As soon as the platform determines that the solution is good, I can go back and remove the parentheses without error. I guess my original question was a matter of understanding the order of operations and ignoring the on-platform error in the exercise.