Exercise 5: Write a python program that reads from a text file whose name is provided by the user (see a sample below) blood glucose readings recorded during the last week. Each line contains a...


Exercise 5:<br>Write a python program that reads from a text file whose name is provided by the user (see a<br>sample below) blood glucose readings recorded during the last week. Each line contains a<br>certain number of blood glucose readings followed by the patient id. Your program should then<br>display for each patient, their id number, the number of readings, the average value of the<br>readings followed by the patient status (Normal range: 90–120 mg/dl, Low range: less than 90<br>mg/dl, High otherwise). Your program should consider the following erroneous cases and<br>display appropriate message as shown in the sample output below:<br>• The file does not open/exist<br>• The readings are invalid (non-integer values or negative) or missing, in which case a<br>ValueError exception should be raised and the processing should continue.<br>Enter input filename: patients.txt<br>Patient Id<br>#Readings Average Status<br>==========<br>=========<br>=======<br>======<br>120 150 150 P1111<br>P1111<br>3<br>140<br>High<br>100 90 90 100 P2222<br>P2222<br>4<br>95<br>Normal<br>12a 100 120 P3333<br>P3333<br>Invalid readings<br>50 70 P4444<br>P4444<br>2<br>60<br>Low<br>P5555<br>P5555<br>No readings<br>Sample input file<br>Sample output<br>

Extracted text: Exercise 5: Write a python program that reads from a text file whose name is provided by the user (see a sample below) blood glucose readings recorded during the last week. Each line contains a certain number of blood glucose readings followed by the patient id. Your program should then display for each patient, their id number, the number of readings, the average value of the readings followed by the patient status (Normal range: 90–120 mg/dl, Low range: less than 90 mg/dl, High otherwise). Your program should consider the following erroneous cases and display appropriate message as shown in the sample output below: • The file does not open/exist • The readings are invalid (non-integer values or negative) or missing, in which case a ValueError exception should be raised and the processing should continue. Enter input filename: patients.txt Patient Id #Readings Average Status ========== ========= ======= ====== 120 150 150 P1111 P1111 3 140 High 100 90 90 100 P2222 P2222 4 95 Normal 12a 100 120 P3333 P3333 Invalid readings 50 70 P4444 P4444 2 60 Low P5555 P5555 No readings Sample input file Sample output

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here