Can you please help!


I’m very new at this!
I’m slightly confused why in the picture below grade = “F”
and is assumed F right on the second line.

I put it, wrongly, on the last line like:
elif gpa >= 1.0:
grade = “D”
else gpa >= 0.0:
grade = “F”

Thank you very very much!,

Also, why do we use “return” at the end instead of print(grade_converter).

Hi there!

Putting grade on the second line can be thought of as a “base case” or the starting point. Not only does it help write fewer conditionals, in more complicated functions you will need it to properly establish the control flow. It is just conceptual in this example as the variations of what can happen are simple.

In terms of print and return, you should consider what each action does, and what functions are used for. Printing essentially doesn’t do anything other than write on the terminal output… it doesn’t change any variable, or affect anything whatsoever.
When you return something from a function, you can use it for other purposes.

Return is vital for how programs are built. Print usually serves to just help us track what’s happening. Entire programs can run without printing, while it will be rare to see a program that never uses return.


Hi Toastedpitabread!

I greatly appreciate you being generous with your time.

Your explanation of print vs return helps me understand this fundamental concept.

Thank you very much!

1 Like