In this Python oops program, we will create a school management system using Python classes. The code demonstrates a basic implementation of a school management system using Python with the help of the below-given steps.
School management system using Python
Steps to solve the program
- The School class represents a school and has attributes like name, students, teachers, and courses. The __init__ method initializes these attributes.
- It also has methods to add and remove students, teachers, and courses from the school. These methods modify the respective lists by appending or removing the provided objects.
- The Student class represents a student and has attributes like name and grade. The __init__ method initializes these attributes.
- It also has methods to enroll and drop courses. The enroll_course method calls the add_student method of the Course class, and the drop_course method calls the remove_student method of the Course class.
- The Teacher class represents a teacher and has attributes like name and subject. The __init__ method initializes these attributes.
- It also has methods to assign and unassign courses. The assign_course method calls the add_teacher method of the Course class, and the unassign_course method calls the remove_teacher method of the Course class.
- The Course class represents a course and has attributes like name, students, and teacher. The __init__ method initializes these attributes.
- It also has methods to add and remove students, and add and remove a teacher for the course. These methods modify the respective attributes accordingly.The remaining part of the code demonstrates the usage of the class structure:
- An instance of the School class is created with the name “ABC School”.
- Instances of the Student class are created with different names and grades, and they are added to the school using the add_student method.
- Instances of the Teacher class are created with names and subjects, and they are added to the school using the add_teacher method.
- Instances of the Course class are created with names, and they are added to the school using the add_course method.
- Students are enrolled in courses using the enroll_course method, and teachers are assigned to courses using the assign_course method.
- Finally, the details of the school, students, teachers, and courses are printed using a series of loops.
Output:
Related Articles
Write a Python Class Structure for Employee Management Application.
Write a Python Class with @property decorator.
Write a Python Class structure with module-level Import.
Create 5 different Python Classes and access them via a single class object.
Create 5 Python classes and set up multilevel inheritance among all the classes.
Set Instance variable data with setattr and getattr methods.