1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Object-Oriented Programming in Python

Connected

Exercise

Create a subclass

The purpose of child classes, or sub-classes, is to customize and extend the functionality of the parent class.

Recall the Employee class from earlier in the course. In most organizations, managers have more privileges and responsibilities than regular employees. So it would make sense to introduce a Manager class that has more functionality than Employee.

But a Manager is still an employee, so the Manager class should be inherited from the Employee class.

In this exercise, you'll create a Manager child class and, later in the course, you'll add specific functionality to the class.

Instructions

100 XP
  • Add a Manager class that inherits from Employee.
  • Use a keyword to leave the Manager class empty.
  • Create an object called mng using the Manager class, setting the name to "Debbie Lashko" and salary to 86500.
  • Print the name attribute of mng.