Quarterly diagnostics X69853


Statement
 

pdf   zip

html

A hospital stores in a list of lists the count of diagnoses made each week. Each diagnosis is stored in a list along with the number of the week and the number of cases.

Design a function stats_diag(ldiags) which, given a list ldiags with the diagnoses of one trimester (12 weeks), returns a dictionary that associates each diagnosis with the list of the number of cases that have occurred in the 12 weeks of the trimester.

Sample session
>>> ldiags = [['Conjuntivitis', 8, 17], ['Fractura', 3, 14],
...       ['Conjuntivitis', 4, 15], ['Infarto', 11, 18],
...       ['Conjuntivitis', 11, 18], ['Fractura', 6, 16],
...       ['Conjuntivitis', 2, 18], ['Fractura', 7, 10],
...       ['Infarto', 8, 15], ['Neumonía', 4, 38],
...       ['Fractura', 12, 6], ['Infarto', 2, 20],
...       ['Conjuntivitis', 6, 25], ['Conjuntivitis', 5, 14],
...       ['Fractura', 8, 13], ['Infarto', 12, 18], ['Neumonía', 7, 28],
...       ['Neumonía', 12, 34], ['Fractura', 2, 13], ['Infarto', 4, 25],
...       ['Conjuntivitis', 3, 17], ['Conjuntivitis', 7, 20],
...       ['Infarto', 9, 18], ['Conjuntivitis', 10, 19], ['Neumonía', 8, 32],
...       ['Fractura', 11, 19], ['Neumonía', 3, 40], ['Infarto', 6, 22],
...       ['Fractura', 4, 12], ['Neumonía', 5, 31], ['Conjuntivitis', 9, 17],
...       ['Fractura', 9, 10], ['Infarto', 7, 18], ['Neumonía', 11, 40],
...       ['Infarto', 1, 17], ['Infarto', 5, 12],
...       ['Conjuntivitis', 1, 24], ['Fractura', 1, 2],
...       ['Infarto', 10, 18], ['Neumonía', 9, 46], ['Fractura', 10, 17],
...       ['Neumonía', 10, 39], ['Neumonía', 2, 35], ['Neumonía', 6, 35],
...       ['Conjuntivitis', 12, 9], ['Infarto', 3, 24], ['Neumonía', 1, 20],
...       ['Fractura', 5, 12]]
>>> sd = stats_diag(ldiags)
>>> if sd != {'Conjuntivitis': [24, 18, 17, 15, 14, 25, 20, 17, 17, 19, 18, 9],
...       'Neumonía': [20, 35, 40, 38, 31, 35, 28, 32, 46, 39, 40, 34],
...       'Fractura': [2, 13, 14, 12, 12, 16, 10, 13, 10, 17, 19, 6],
...       'Infarto': [17, 20, 24, 25, 12, 22, 18, 15, 18, 18, 18, 18]}:
...     print(sd)
Information
Author
InfBesos
Language
English
Translator
Original language
Spanish
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python