What am I missing in my code?

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?

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  |

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.

Is this the code?

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

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:
def graduation_reqs(gpa, credits):
if (gpa >= 2.0) and (credits >= 120):
return “You have enough credits to graduate!”

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

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

2 Likes

You’re welcome! Lesson here? Read and follow instructions closely.

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.

They really don’t give you much to set it up the way you did. The instructions tell you what to do but are not very helpful. Even with the previous lessons I still would not have been able to do the whole “thought process exercise” you came up with. It would have been more helpful if there was a lesson that actually showed me what you did. The first part of this lesson literally reads as if it’s just telling you to plug in the problems in statement_1 and statement_2. When you do, it checks out as if you did it properly and moves you on to the second part.

1 Like

Difficult to speak for the author of that course, which was written more than five years ago and the author is likely long gone. Speaking for contributors here on the forums, we are all non-employees (only members/consumers on CC’s platforms).

One can perhaps model an approach similar to that example by sketching on paper to explore ideas and formulate working code, or simply answer the question, such as above. The author, or future authors may, in retrospect take your advice under consideration and develop thought process hints, in addition to examples.

Bottom line, on any online platform, especially one like this targeting self-learners we are largely on our own and must take action on our own to mitigate any confusion or difficulty, such as search or reading, or as mentioned above, sketching to zero in on the concepts as they relate to the question/problem. We need to put the brakes on when we run into snags, as opposed to racing forward. Clear the air at every step and expect to be confused, a lot. Take the time to properly understand and your progress will be, ‘steady as she goes.’

1 Like

No, I get it. Sorry for my little criticism, wasn’t towards you or anything. Just something I noticed while trying to solve. It’s like one of those situations that you get into when you feel that the lesson wasn’t explained very well, and it might be a good idea to pause and find out what I’m really supposed to be doing. You seem to be very helpful on here, appreciate it. I am understanding a lot of this pretty well, with the exception of lesson 7 hiccups.

1 Like