Student Grade Manager
Intermediate-Advanced Project
Manage student records and calculate statistics using dictionaries, OOP, and file persistence.
Project Overview
Goal: Store students and calculate averages.
Concepts: Dictionaries, OOP, file persistence, exception handling.
Key Features:
- โข Add/remove students
- โข Record grades for multiple subjects
- โข Calculate GPA and averages
- โข Generate grade reports
- โข Export data to CSV
Technologies & Concepts:
Starter Code
๐ก Note: Interactive Code
This is a command-line app that uses input() for user interaction. The browser demo below shows a simplified version. For the full interactive experience, copy the code below and run it in your local Python environment (IDLE, VS Code, or terminal).Jump to the Browser Demo.
Here's a functional starting version of your app. Copy it to your local Python editor and run it.
class Student:
def __init__(self, name):
self.name = name
self.grades = []
def add_grade(self, grade):
if 0 <= grade <= 100:
self.grades.append(grade)
print(f"โ Added grade {grade} for {self.name}")
else:
print("Grade must be between 0 and 100!")
def average(self):
return sum(self.grades) / len(self.grades) if self.grades else 0
def get_letter_grade(self):
avg = self.average()
if avg >= 90: return "A"
elif avg >= 80: return "B"
elif avg >= 70: return "C"
elif avg >= 60: return "D"
else: return "F"
students = {}
def menu():
print("\n๐ Student Grade Manager")
print("1. Add Student")
print("2. Add Grade")
print("3. View All Students")
print("4. View Student Report")
print("5. Exit")
while True:
menu()
choice = input("\nChoice: ")
if choice == "1":
name = input("Student name: ")
students[name] = Student(name)
print(f"โ Added {name}")
elif choice == "2":
name = input("Student name: ")
if name in students:
try:
grade = float(input("Grade: "))
students[name].add_grade(grade)
except ValueError:
print("Please enter a valid number!")
else:
print("Student not found!")
elif choice == "3":
if not students:
print("No students yet!")
else:
print("\n๐ All Students:")
for s in students.values():
print(f" {s.name}: {s.average():.1f} ({s.get_letter_grade()})")
elif choice == "4":
name = input("Student name: ")
if name in students:
s = students[name]
print(f"\n๐ Report for {s.name}")
print(f"Grades: {s.grades}")
print(f"Average: {s.average():.1f}")
print(f"Letter Grade: {s.get_letter_grade()}")
else:
print("Student not found!")
elif choice == "5":
print("Goodbye!")
break๐ How to Run Locally:
- Copy the code above
- Save it as
grade_manager.py - Open terminal and run:
python grade_manager.py - Follow the interactive menu to manage students
๐ฎ Browser Demo (Simplified Version)
This browser version demonstrates the core logic without user input. Click Run to see it work!
Grade Manager Demo
class Student:
def __init__(self, name):
self.name = name
self.grades = []
def add_grade(self, grade):
if 0 <= grade <= 100:
self.grades.append(grade)
print(f"โ Added grade {grade} for {self.name}")
else:
print("Grade must be between 0 and 100!")
def average(self):
return sum(self.grades) / len(self.grades) if self.grades else 0
def get_letter_grade(self):
avg = self.average()
...Enhancement Ideas ๐
1. CSV Export
Export student data to CSV format using the csv module for easy import into Excel.
2. Multiple Subjects
Track grades for different subjects (Math, English, Science) and calculate subject-specific averages.
3. Grade Statistics
Calculate class statistics like median, mode, highest, and lowest grades.
4. Persistent Storage
Save and load student data using JSON files so data persists between sessions.
5. Search & Filter
Add search functionality and filter students by grade range or letter grade.
Next Steps
- Run the starter code and test basic functionality
- Add input validation for all user inputs
- Implement JSON file storage for persistence
- Create a proper grade report format
- Add multiple subject support
- Build class-wide statistics features
- Document and share your project!