docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a student grade tracking system that persists and restores grade data with automatic list initialization for new students.
The system should track student grades across multiple subjects. When a new student is added or when loading data from storage, the system should automatically initialize an empty list of grades if the student doesn't have any yet.
Implement a GradeTracker class with the following behavior:
from typing import List
class GradeTracker:
"""Tracks student grades with automatic list initialization."""
def __init__(self):
"""Initialize the grade tracker."""
pass
def add_grade(self, student_name: str, grade: float) -> None:
"""
Add a grade for a student.
Args:
student_name: The name of the student
grade: The numerical grade to add
"""
pass
def get_grades(self, student_name: str) -> List[float]:
"""
Get all grades for a student.
Args:
student_name: The name of the student
Returns:
List of grades for the student (empty list if no grades)
"""
pass
def to_json(self) -> dict:
"""
Serialize the grade tracker to a JSON-compatible dictionary.
Returns:
Dictionary representation of the grade tracker
"""
pass
@staticmethod
def from_json(data: dict) -> 'GradeTracker':
"""
Deserialize a grade tracker from a JSON-compatible dictionary.
Args:
data: Dictionary representation of the grade tracker
Returns:
A new GradeTracker instance with the deserialized data
"""
passProvides JSON serialization and deserialization support for Python objects.