{"id":160,"date":"2026-09-03T07:03:00","date_gmt":"2026-09-03T07:03:00","guid":{"rendered":"https:\/\/alpeshconnect.in\/blog\/?p=160"},"modified":"2026-09-03T07:04:59","modified_gmt":"2026-09-03T07:04:59","slug":"create-class-schoolnamelocation-its-child-class-teachersubjectsalary-and-its-child-class-classteacherclass_name-section-display-complete-detail","status":"publish","type":"post","link":"https:\/\/alpeshconnect.in\/blog\/2026\/09\/03\/create-class-schoolnamelocation-its-child-class-teachersubjectsalary-and-its-child-class-classteacherclass_name-section-display-complete-detail\/","title":{"rendered":"Create class School. Display complete detail"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Create class School(name,location), its child class Teacher(subject,salary), and it&#8217;s child class ClassTeacher(class_name, section). Display complete detail<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Parent class<br>class School:<br>    def __init__(self, name, location):<br>        self.name = name<br>        self.location = location<br><br>    def display_school(self):<br>        print(f\"School Name: {self.name}\")<br>        print(f\"Location: {self.location}\")<br><br># Child class of School<br>class Teacher(School):<br>    def __init__(self, name, location, subject, salary):<br>        # Calling the constructor of the parent class<br>        super().__init__(name, location)<br>        self.subject = subject<br>        self.salary = salary<br><br>    def display_teacher(self):<br>        self.display_school()<br>        print(f\"Subject: {self.subject}\")<br>        print(f\"Salary: \u20b9{self.salary}\")<br><br># Child class of Teacher<br>class ClassTeacher(Teacher):<br>    def __init__(self, name, location, subject, salary, class_name, section):<br>        # Calling the constructor of the parent class (Teacher)<br>        super().__init__(name, location, subject, salary)<br>        self.class_name = class_name<br>        self.section = section<br><br>    def display_all(self):<br>        # Displaying all details using methods from parent classes<br>        self.display_teacher()<br>        print(f\"Class: {self.class_name}\")<br>        print(f\"Section: {self.section}\")<br><br># --- Creating an object and displaying details ---<br># Using data<br>ct = ClassTeacher(\"Delhi Public School\", \"New Delhi\", \"Computer Science\", 85000, \"10\", \"A\")<br><br>print(\"--- Complete Details of the Class Teacher ---\")<br>ct.display_all()<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create class School(name,location), its child class Teacher(subject,salary), and it&#8217;s child class ClassTeacher(class_name, section). Display complete detail # Parent classclass School: def __init__(self, name, location): self.name = name self.location = location def display_school(self): print(f&#8221;School Name: {self.name}&#8221;) print(f&#8221;Location: {self.location}&#8221;)# Child class of Schoolclass Teacher(School): def __init__(self, name, location, subject, salary): # Calling the constructor of the parent [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":96,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,3],"tags":[52,25,26,45],"class_list":["post-160","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aiopd","category-bca","tag-aiopd","tag-bca","tag-bca-paper-solution","tag-python"],"_links":{"self":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":4,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":164,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions\/164"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media\/96"}],"wp:attachment":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}