+ 1

Output of the cofe

class Patient: def __init__(self, patient_id, name, age, ailment): self.patient_id = patient_id self.name = name self.age = age self.ailment = ailment def display(self): return f"Patient ID: {self.patient_id} | Name: {self.name} | Age: {self.age} | Ailment: {self.ailment}" class Doctor: def __init__(self, doctor_id, name, specialty): self.doctor_id = doctor_id self.name = name self.specialty = specialty def display(self): return f"Doctor ID: {self.doctor_id} | Name: {self.name} | Specialty: {self.specialty}" class Hospital: def __init__(self): self.patients = [] self.doctors = [] self.appointments = {} def add_patient(self, patient): self.patients.append(patient) print(f"Patient {patient.name} registered successfully!") def add_doctor(self, doctor): self.doctors.append(doctor) print(f"Doctor {doctor.name} added successfully!") def schedule_appointment(self, patient_id, doctor_id): patient = next((p for p in self.patients if p.patient_id == patient_id), None) doctor = next((d for d in self.doctors if d.doctor_id == doctor_id), None) if patient and doctor: self.appointments[patient_id] = doctor_id print(f"Appointment scheduled for {patient.name} with Dr. {doctor.name}.") else: print("Invalid patient or doctor ID!") def display_patients(self): print("\nList of Patients:") for patient in self.patients: print(patient.display()) def display_doctors(self): print("\nList of Doctors:") for doctor in self.doctors: print(doctor.display()) def display_appointments(self): print("\nScheduled Appointments:") for patient_id, doctor_id in self.appointments.items(): patient = next(p for p in self.patients if p.patient_id == patient_id) doctor = next(d for d in self.doctors if d.doct

11th Mar 2025, 8:14 PM
Srushti Yadav
Srushti Yadav - avatar
1 Antwort
+ 4
Srushti Yadav did you have a question as the code is well constructed but obviously not complete due to it being a wall of code... Can you please clarify ? https://sololearn.com/compiler-playground/cnq9CUDENm9Z/?ref=app
12th Mar 2025, 4:57 AM
BroFar
BroFar - avatar