Answered step by step
Verified Expert Solution
Question
1 Approved Answer
from datetime import datetime categories = [ General Consultation, Obstetrics and Gynaecology, Minor Surgery ] # Initial data with today's date initial _ data
from datetime import datetime categories General Consultation", "Obstetrics and Gynaecology", "Minor Surgery" # Initial data with today's date initialdata "General Consultation": Joyce Wong", datetime.nowstrftimeYmdCeline Kang", datetime.nowstrftimeYmd "Obstetrics and Gynaecology": Mandy Pang", datetime.nowstrftimeYmdNancy Lee", datetime.nowstrftimeYmd "Minor Surgery": David Ong", datetime.nowstrftimeYmdEmily Tan", datetime.nowstrftimeYmd queues for category in categories: queuescategory for category, patients in initialdata.items: for patientname, scheduledate in patients: queuescategoryappendname: patientname, "date": scheduledate, "time": # Initialize time to empty string def printqueues: for category, queue in queues.items: printf
category queue:" for patient in queue: printfpatientnamepatientdatepatienttime if not queue: printNo patients in queue." def callpatientcategory: if queuescategory: patient queuescategorypop scheduletime inputfEnter the schedule time for patientname on patientdateHH:MM: patienttime scheduletime printfPatient to be called: patientname printfScheduled time: patientdatepatienttime else: printNo patients in queue." def addpatient: name inputEnter patient name: scheduledate datetime.nowstrftimeYmd printPlease choose a category for the patient:" for i category in enumeratecategories: printficategory categorychoice intinput if categorychoice lencategories: queuescategoriescategorychoiceappendname: name, "date": scheduledate, "time": printqueues else: printInvalid choice, please try again." def main: while True: action input
Would you like to call patients? yesno: lower if action "yes": printPlease choose a category to call a patient:" for i category in enumeratecategories: printficategory categorychoice intinput if categorychoice lencategories: callpatientcategoriescategorychoice printqueues else: printInvalid choice, please try again." elif action no: addpatient else: printExiting program." break if namemain: main add comments and explain this code every single line
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started