📘 Introduction

In this project, you’ll develop a Student Grades Analyzer in Python that can:
- Store student names and their grades
- Calculate averages
- Identify top and lowest performers
- Display useful statistics
This project helps you strengthen your skills with lists, dictionaries, loops, and data analysis logic.
🧠 Key Concepts Covered
| Concept | Description |
|---|---|
| Lists & Dictionaries | Store student names and grades efficiently. |
| Loops | Iterate through data for calculations. |
| Conditionals | Compare grades and find top performers. |
| Data Analysis | Compute average, max, and min values. |
🧰 What You’ll Need
- Python 3 installed
- Basic knowledge of loops, lists, and dictionaries
- (Optional) Familiarity with CSV files for data import/export
💻 Step-by-Step Code
File Name: grades_analyzer.py
# 🎓 Student Grades Analyzer
def add_student(students):
name = input("Enter student name: ")
grades = input("Enter grades separated by commas: ")
grade_list = [float(g.strip()) for g in grades.split(",")]
students[name] = grade_list
print(f"✅ {name} added successfully!\n")
def calculate_average(grades):
return sum(grades) / len(grades)
def show_statistics(students):
print("\n📊 Class Statistics:\n")
averages = {name: calculate_average(grades) for name, grades in students.items()}
for name, avg in averages.items():
print(f"{name}: {avg:.2f}")
top_student = max(averages, key=averages.get)
lowest_student = min(averages, key=averages.get)
class_average = sum(averages.values()) / len(averages)
print("\n🏅 Top Student:", top_student, f"({averages[top_student]:.2f})")
print("📉 Lowest Student:", lowest_student, f"({averages[lowest_student]:.2f})")
print(f"📘 Class Average: {class_average:.2f}\n")
def main():
students = {}
while True:
print("🎓 Student Grades Analyzer")
print("1. Add Student")
print("2. View Statistics")
print("3. Exit")
choice = input("Choose an option (1-3): ")
if choice == "1":
add_student(students)
elif choice == "2":
if students:
show_statistics(students)
else:
print("⚠️ No students added yet.\n")
elif choice == "3":
print("👋 Goodbye!")
break
else:
print("❌ Invalid choice. Try again.\n")
if __name__ == "__main__":
main()
🧩 Example Output
🎓 Student Grades Analyzer
1. Add Student
2. View Statistics
3. Exit
Choose an option (1-3): 1
Enter student name: Alice
Enter grades separated by commas: 90, 85, 88
✅ Alice added successfully!
🎓 Student Grades Analyzer
1. Add Student
2. View Statistics
3. Exit
Choose an option (1-3): 2
📊 Class Statistics:
Alice: 87.67
🏅 Top Student: Alice (87.67)
📉 Lowest Student: Alice (87.67)
📘 Class Average: 87.67
🚀 Bonus Improvements
- Save and load student data from a CSV file using the
csvmodule. - Add grading categories (tests, homework, projects).
- Use Matplotlib to visualize grade distributions.
- Create a GUI version using
tkinter.
🧠 Summary
- You built a Student Grades Analyzer that stores data dynamically.
- You used loops, lists, and dictionaries to process and analyze information.
- You learned how to calculate averages and generate performance insights.