
Problem
Solution
Submissions
Student Management System
Certification: Advanced Level
Accuracy: 50%
Submissions: 2
Points: 10
Implement a Python class called StudentManagementSystem
that allows adding students, assigning grades, calculating grade point averages (GPAs), and retrieving student information. Each student should have a unique ID, name, and a dictionary of courses with their respective grades.
Example 1
- Input: sms = StudentManagementSystem()
- Operations: sms.add_student(101, "Alice Johnson")
- Operations: sms.assign_grade(101, "Math", 85)
- Operations: sms.assign_grade(101, "Science", 90)
- Operations: sms.assign_grade(101, "History", 78)
- Output: 84.33
- Explanation:
- Step 1: Create a StudentManagementSystem instance.
- Step 2: Add a student with ID 101 and name "Alice Johnson".
- Step 3: Assign grades for three courses.
- Step 4: Calculate and return the average GPA.
Example 2
- Input: sms = StudentManagementSystem()
- Operations: sms.add_student(102, "Bob Smith")
- Operations: sms.assign_grade(102, "History", 92)
- Operations: sms.assign_grade(102, "Physics", 88)
- Output: {'id': 102, 'name': 'Bob Smith', 'courses': {'History': 92, 'Physics': 88}, 'gpa': 90.0}
- Explanation:
- Step 1: Create a StudentManagementSystem instance.
- Step 2: Add a student with ID 102 and name "Bob Smith".
- Step 3: Assign grades for two courses.
- Step 4: Retrieve and return the student's information including GPA.
Constraints
- Student IDs must be unique integers.
- Course names must be strings.
- Grades must be integers between 0 and 100.
- Time Complexity: O(1) for adding students, O(n) for calculating GPA where n is the number of courses.
- Space Complexity: O(m*n) where m is the number of students and n is the average number of courses per student.
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Use a dictionary to store student information with IDs as keys
- Implement methods to validate inputs (student existence, grade ranges)
- For GPA calculation, average the grades for all courses
- Consider implementing error handling for invalid operations
- Structure the student data as nested dictionaries