In this program it says patients_data.txt is not defined. Can you please check where am I going wrong on this.# Print Details of the programprint(“This program reads a file patients_data.txt “)print(“stores each line in a dictionary. Then this program have options like.”)print(“Find a particular patient average costs by patient name”)print(“Delete patient data”)print(“Add new patient data”)print(“Write patient data to file”)print(“Show all patient details”)print(“Exit program”)# Function to read filedef file_read_file(): patient_data = {} while True: file_name = input(“nEnter file: “) try: _file = open(file_name, ‘r’) break except FileNotFoundError: print(file_name,” does not exist.”) continue for file_line in _file: file_line = file_line.strip() if len(file_line) != 0: file_line = file_line.split(‘,’) patient_data[file_line[0]] = [file_line[1], file_line[2], file_line[3]] _file.close() return patient_data# Function to find Patient’s average cost of visitsdef Cost_Average(p_info): name = input(“nEnter Patient name: “).title() if name in p_info: total = 0 for cost in p_info[name]: total += int(cost) average = total / 3 print(“Average costs of “+name+”:”,average) else: print(name,”not found!”)# Function to delete Patient datadef deletePatient(p_info): name = input(“nEnter Patient name to delete: “) if name in p_info: del p_info[name] print(“Patient deleted!”) return p_info else: print(name,”not found!”) return p_info# Function to show all Patients datadef showDetails(p_info): print(“n Patient t costs “) for name,costs in p_info.items(): print(name+”t”+str(costs))# Function to add new Patientdef addPatients(p_info): name = input(“nEnter name of the Patient: “) costs = [] for i in range(3): visit_costs = int(input(“Enter costs of visit#”+str(i+1)+”: “)) costs.append(str(visit_costs)) p_info[name] = costs print(“Patient added!”) return p_info# Function to write data into filedef visit_writeData(p_info): while True: try: file_name = input(“nEnter file name to write: “) _file = open(file_name, ‘w’) break except FileNotFoundError: print(file_name,”not found!”) continue for name,costs in p_info.items(): _file.write(name+”,”+”,”.join(costs)+”n”) _file.close() print(“Data written into file.”)visit_data = file_read_ftn()# Loop to simulate menuwhile True: print(“n>>> Menu”) print(“1. Find Patients average”) print(“2. Delete Patient data”) print(“3. Add new Patient” ) print(“4. Write Patients data to file”) print(“5. Show Patient details”) print(“0. Exit”) option = input(“Select option: “) while option not in [‘0′,’1′,’2′,’3′,’4′,’5’]: print(“Invalid option. Try again”) option = int(input(“Select option: “)) if option == ‘1’: Cost_Average(visit_data) elif option == ‘2’: visit_data = deletePatient(visit_data) elif option == ‘3’: visit_data = addPatients(visit_data) elif option == ‘4’: visit_writeData(visit_data) elif option == ‘5’: showDetails(visit_data) else: breakprint(“nThanks for using this program !!!”)Computer ScienceEngineering & TechnologyPython Programming BIM IT-218
solved : In this program it says patients_data.txt is not defined. Ca
How it works
- Paste your instructions in the instructions box. You can also attach an instructions file
- Select the writer category, deadline, education level and review the instructionsÂ
- Make a payment for the order to be assigned to a writer
- Â Download the paper after the writer uploads itÂ
Will the writer plagiarize my essay?
You will get a plagiarism-free paper and you can get an originality report upon request.
Is this service safe?
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
LET THE PROFESSIONALS WRITE YOUR PAPER!