[email protected]
However, if we want to get the personal email address of an employee, we can write another method that will call the Person.get_email() method and get the personal email address of the employee.
class Person: def __init__(self, name, personal_email, contact_number): self.name = name self.email = personal_email self.contact_number = contact_number def get_email(self): return self.email def get_contact_number(self): return self.contact_number class Employee(Person): def __init__(self, name, personal_email, contact_number, company_name, employee_id, company_email): super().__init__(name, personal_email, contact_number) self.company_name = company_name self.employee_id = employee_id self.company_email = company_email def get_company_name(self): return self.company_name def get_employee_id(self): return self.employee_id def get_email(self): return self.company_email def get_personal_email(self): return Person.get_email(self) employee = Employee("Ajay", "[email protected]", "1234", "ABC Company", "0123", "[email protected]") print(employee.get_email()) print(employee.get_personal_email())
The program will print the following output:






0 Comments