Lesson 10
Mini Project: Grade Report
Real programs combine small ideas. This project uses a list, a function, a loop, and conditions.
Start by calculating a value, then build output that a person can understand.
Once it works, change the data and test that the program still behaves correctly.
scores = [70, 85, 90, 55]
def average(values):
return sum(values) / len(values)
print(f"Average: {average(scores):.1f}")
for score in scores:
status = "pass" if score >= 60 else "review"
print(score, status)Check your understanding
How do you compute the mean of a nonempty list nums?
CHALLENGE
Given scores = [70, 85, 90, 55], print the average (75.0) then the number of passing scores (3). A pass is at least 60.
Practice →