In [ ]:
class HealthcareProfessional:
def __init__(self, name):
self.name = name
def perform_duty(self):
raise NotImplementedError("Subclass must implement abstract method")
In [ ]:
class Doctor(HealthcareProfessional):
def perform_duty(self):
return f"Dr. {self.name} is diagnosing patients."
In [3]:
class Nurse(HealthcareProfessional):
def perform_duty(self):
return f"Nurse {self.name} is administering medication."
In [ ]:
professionals = [
Doctor("Andrew"),
Nurse("John")
]
In [4]:
for professional in professionals:
print(professional.perform_duty())
Dr. Smith is diagnosing patients. Nurse Johnson is administering medication.