Content · Programming · Python

Python Build a Student Grade Tracker with Lists

A grade tracker stores numeric scores in a list, computes a total and average, and determines highest and lowest values. Handle an empty class explicitly before dividing. See two practical examples, edge cases and.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

A teacher summarizes scores recorded for a small class.

What You Need to Understand


A grade tracker stores numeric scores in a list, computes a total and average, and determines highest and lowest values. Handle an empty class explicitly before dividing.

When to Use It


A teacher summarizes scores recorded for a small class.

Step-by-Step Python Example


grades = [82, 90, 74, 88]
if grades:
    average = sum(grades) / len(grades)
    print(f"Average: {average:.1f}")
    print("Highest:", max(grades))
    print("Lowest:", min(grades))
else:
    print("No grades recorded")

How the Example Works


The average uses the total divided by the number of students; the guard avoids division by zero.

Example Output


Average: 83.5
Highest: 90
Lowest: 74
75.0

A Second Example


Compare this smaller variation with the main example, then experiment with your own values.

grades = [70, 80]
print(sum(grades) / len(grades))

Important Behavior and Edge Cases


An average alone can hide variation, and values outside the permitted grading range should be validated before entry.

Try It Yourself


Add grades 95 and 100 and check the new average.

Common Beginner Mistakes


  • An average alone can hide variation, and values outside the permitted grading range should be validated before entry.
  • Overlooking how an iterable is consumed, how element positions are chosen, or whether a function creates a new list.

Key Takeaways


  • A grade tracker stores numeric scores in a list, computes a total and average, and determines highest and lowest values.
  • The average uses the total divided by the number of students; the guard avoids division by zero.
  • An average alone can hide variation, and values outside the permitted grading range should be validated before entry.
Share this resourceSend this page to someone who may find it useful.