Question: 1 . Create a Python application that models a basic school system. The system should include two types of people: students and teachers. Each person
Create a Python application that models a basic school system. The system should include two types of people: students and teachers. Each person should have a name and age stored in a dictionary as their attributes, egname: name, age: age Teachers have an additional attribute, the subject they teach, while students have a list of grades. Use inheritance to avoid code duplication.
In your program, you should have three classes points for each class:
a Person Class:
Create a base class called Person that initializes with a name and age.
Store the attributes in a dictionary within the class.
Implement a method getdetails that returns the person's details as a string.
b Student Class:
Create a Student class that inherits from Person.
Add an attribute called grades for storing a list of grades eg in the initializer. This should also be stored together with the name and the age in the attributes dictionary.
Implement a method calculateaveragegrade that calculates and returns the student's average grade.
Override the getdetails method to include average grade information in the returned string.
c Teacher Class:
Create a Teacher class that inherits from Person.
Add an attribute called subject for storing the subject they teach in the initializer. This should also be stored together with the name and the age in the attributes dictionary.
Override the getdetails method to include the subject information in the returned string.
In your main program:
Instantiate a few Student and Teacher objects with various details.
Call the getdetails method on each instance and print the results to demonstrate that your system works.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
