Student Enloremant
Student Enloremant
python
class Student:
def __init__(self, student_id, name):
self.student_id = student_id
self.name = name
self.courses = []
def view_courses(self):
print(f"Courses enrolled by {self.name}:")
for course in self.courses:
print(course)
class EnrollmentSystem:
def __init__(self):
self.students = {}
def main():
enrollment_system = EnrollmentSystem()
enrollment_system.add_student(student1)
enrollment_system.add_student(student2)
enrollment_system.enroll_student_in_course(1, "Mathematics")
enrollment_system.enroll_student_in_course(1, "Science")
enrollment_system.enroll_student_in_course(2, "History")
student1.view_courses()
student2.view_courses()
if __name__ == "__main__":
main()
In the code above, we define two main classes: Student and EnrollmentSystem. The
Student class captures the essential attributes of a student, including their
identification and name, while also allowing for the enrollment and viewing of
courses. The EnrollmentSystem class serves as the overarching framework for
managing multiple students and their enrollments.
The main function serves as the entry point for the program, where we create an
instance of the enrollment system, add students, and facilitate their enrollment in
various courses. Finally, each student can view their enrolled courses,
demonstrating the system's ability to manage academic records efficiently.