Question: PYTHON The daily_summary function takes a dict argument in the form of the data structure above,(a dict whose keys are dates (str), each associated with
PYTHON The daily_summary function takes a dict argument in the form of the data structure above,(a dict whose keys are dates (str), each associated with an inner dict whose keys are drug names (str)and whose associated value is a tuple of int transactions)and returns a dictionary (dict or defaultdict) whose keys are dates, each associated with a dictionary whose keysare drug names (str) and whose associated values is the net number of pills distributed/received: e.g, if the transactions are the tuple (4, 2, -3) the net number of pills is 4+2-3 = 3.So calling this function with the db1 dictionary shown above daily_summary( db1 )returns a dictionary that contains the following information {'2016-04-01': {'Azor': 95, 'Benz': 3}, '2016-04-02': {'Azor': -4, 'Caml': 1, 'Depr': -3}} Of course, dictionaries can print their key/values in any order, because they are not ordered.
db1 = {'2016-04-02': {'Azor': (-5, -2, 3, -1, -7), 'Efos': (-3, 20, -7), 'Caml': (4, 6, -2, 20, -8, -3)}, '2016-04-03': {'Benz': (-4, 16), 'Azor': (-4,), 'Efos': (4, 1, 30), 'Caml': (-2, -2, -3, -2)}, '2016-04-01': {'Benz': (4, 2, -3, 20), 'Depr': (30, -2, -5, -10, -2), 'Azor': (20, -3, -3, 1), 'Efos': (4, -7), 'Caml': (4, 6, -2, 1, -8, -3)}} def daily_summary(db : {str:{str:(int,)}}) -> {str:{str:int}}: Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
