Build a Grade Calculator
Advanced · Write the code · from Python Functions: Define, Call, and Return Values
From the lesson: Python Functions: Define, Call, and Return Values
Imagine you have a favorite recipe for pancakes. Every Sunday morning, you follow the same steps: mix flour, crack eggs, pour batter, flip. You don't reinvent the recipe each time - you just follow the one you already know.
Read the lessonWrite a function called get_grade that takes a numeric score (0-100) and returns a letter grade as a string:
'A''B''C''D''F'# Define your function here
# Test it
print(get_grade(95))
print(get_grade(83))
print(get_grade(72))
print(get_grade(65))
print(get_grade(45))
What Check runs
Your code runs first, then each of these lines. The output must match exactly.
| Runs | Expected output |
|---|---|
| print(get_grade(95)) | A |
| print(get_grade(83)) | B |
| print(get_grade(72)) | C |
More Function exercises
- Say HelloBeginner
- Predict the OutputBeginner
- Area of a RectangleBeginner
- Fix the Broken FunctionIntermediate
- Temperature ConverterIntermediate
All Python exercises · 50 practice problems · Functions quiz