Question: PYTHON please refer to the code below and Add more objects , delete one record update one of the attributes, and search --------- class Hospital:

PYTHON
please refer to the code below
and Add more objects , delete one record update one of the attributes, and search
---------
class Hospital:
def __init__(self):
self.patients = []
self.doctors = []
def add_patient(self, patient):
self.patients.append(patient)
def add_doctor(self, doctor):
self.doctors.append(doctor)
def remove_patient(self, patient):
self.patients.remove(patient)
def remove_doctor(self, doctor):
self.doctors.remove(doctor)
def update_patient(self, patient, updated_patient):
self.patients.remove(patient)
self.patients.append(updated_patient)
def update_doctor(self, doctor, updated_doctor):
self.doctors.remove(doctor)
self.doctors.append(updated_doctor)
def view_all_records(self, index):
if index == 0:
for i in range(len(ls)):
print(f'Patient Name: {ls[i].name} | Age: {ls[i].age} | Gender: {ls[i].gender} | Disease: {ls[i].disease} | Doctor Name: {ls[i].doctor_name} | Blood Type: {ls[i].blood_type}')
else:
for j in range(len(ls)):
print(f'Doctor Name: {ls[j].name} | Specialty: {ls[j].specialty} | Experience: {ls[j].experience}')
class Patient(Hospital):
def __init__(self, name, age, gender, disease, doctor_name, blood_type):
self.name = name
self.age = age
self.gender = gender
self.disease = disease
self.doctor_name = doctor_name
self.blood_type = blood_type
class Doctor(Hospital):
def __init__(self, name, specialty, experience):
self.name = name
self.specialty = specialty
self.experience = experience
ls = [] #list of patients....define another one for doctors
ls.append(Patient('andy', 23, 'M', 'COVID', 'Adams', 'C-'))
Hospital.view_all_records(ls,0)
ls=[]
ls.append(Doctor("Adams","RDS","20 Years"))
Hospital.view_all_records(ls,1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!