Create class School. Display complete detail

Create class School. Display complete detail

Create class School(name,location), its child class Teacher(subject,salary), and it’s child class ClassTeacher(class_name, section). Display complete detail

# Parent class
class School:
def __init__(self, name, location):
self.name = name
self.location = location

def display_school(self):
print(f"School Name: {self.name}")
print(f"Location: {self.location}")

# Child class of School
class Teacher(School):
def __init__(self, name, location, subject, salary):
# Calling the constructor of the parent class
super().__init__(name, location)
self.subject = subject
self.salary = salary

def display_teacher(self):
self.display_school()
print(f"Subject: {self.subject}")
print(f"Salary: ₹{self.salary}")

# Child class of Teacher
class ClassTeacher(Teacher):
def __init__(self, name, location, subject, salary, class_name, section):
# Calling the constructor of the parent class (Teacher)
super().__init__(name, location, subject, salary)
self.class_name = class_name
self.section = section

def display_all(self):
# Displaying all details using methods from parent classes
self.display_teacher()
print(f"Class: {self.class_name}")
print(f"Section: {self.section}")

# --- Creating an object and displaying details ---
# Using data
ct = ClassTeacher("Delhi Public School", "New Delhi", "Computer Science", 85000, "10", "A")

print("--- Complete Details of the Class Teacher ---")
ct.display_all()