# FAQ: Control Flow - Boolean Operators: and

#1

This community-built FAQ covers the “Boolean Operators: and” exercise from the lesson “Control Flow”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

#2

Hi,

I’m stuck on exercise 1. Statement two is only showing py (4 * 2

I’ve reported the missing expression, but what does “py” mean in this context? The expression listed for Statement one is also preceded by “py”.

#3

Nothing special. `py` is the extension used on Python files but I’ve never seen it have any special meaning in code context. Could be a typo or something wonky with the page composer on the backend.

#4

I have also seen this happen to me just now. It seems like the instructions code has a slight typo that needs to be fixed. I just skipped to the solution so I could continue.

#5

statement_one = True and False

statement_two = True and True

For other people that don’t want to skip the entire exercise you can use booleans to bypass that particular step since yeah, the expressions are broken currently.

#6

I am stuck on step 2. I complete step 1 by making statement_one and statement_two equal to the provided expressions. When I try to do step 2, though, my function is exactly the same as the solution, but it won’t give me the appropriate return until I change the statement_one and statement_two to equal False and True. Can anyone explain what those two statements have to do with the step 2 function?

#7

If you are doing this,

``````statement_one = (2 + 2 + 2 >= 6) and (-1 * -1 < 0)

statement_two = (4 * 2 <= 8) and (7 - 1 == 6)
``````

Then Reset and start over. That is not what we are expected to do. This is a thought process exercise.

In our heads we should be able to examine each operand and evaluate…

``````(2 + 2 + 2 >= 6)  =>  True, or False?  T  |
=>                                    and |  False
(-1 * -1 < 0)     =>  True, or False?  F  |

(4 * 2 <= 8)      =>  True, or False?  T  |
=>                                    and |  True
(7 - 1 == 6)      =>  True, or False?  T  |``````

#8

Thank you, I get that portion now, but for step two, even when I set statement_one = False and statement _two = True, I still get the same error. I literally copy and pasted the solution, which was exactly the same as what I had written and when I copy and pasted the solution it worked, but with what I had written it didn’t. Is there something I’m missing.

#9

Is this the code?

``````def graduation_reqs(gpa, credits):
if gpa >= 2.0 and credits >= 120:
return "You meet the requirements to graduate!"
``````

#10

Yes. When I type that in it marks the step with an X and I get the statement "Expected `graduation_reqs()` with test values gpa = 2.0 and credits = 120 to return “You meet the requirements to graduate!”

I copy and paste it from the solution, it’s marked with a check even though they both say exactly the same thing.

This is what I typed:
if (gpa >= 2.0) and (credits >= 120):
return “You have enough credits to graduate!”

This is the provided solution:
if (gpa >= 2.0) and (credits >= 120):
return “You meet the requirements to graduate!”

#11

Hah nevermind, I see what I missed. The return statement. Well I feel like a dummy now. Thank you for helping!

#12

Since we are not grouping operations, no parens are needed.

``````if gpa >= 2.0 and credits >= 120
``````

The relationship operators have precedence over AND, so those operations are carried out first.

#13

The way I see it you need to call the function as follow:

``````def graduation_reqs(credits, gpa):
if credits >= 120 and gpa >= 2.0:
return "You meet the requirements to graduate!"

``````

or add print to the return statement in the function then call the function:

``````def graduation_reqs(credits, gpa):
if credits >= 120 and gpa >= 2.0:
return print("You meet the requirements to graduate!")