Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago