Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python code!! Now assume that you kept the log of number of hours you studied for your courses throughout the semester and stored that data

Python code!!

Now assume that you kept the log of number of hours you studied for your courses throughout the semester and stored that data as a list of dictionaries. This list includes a dictionary for each week you recorded your log. Assuming you kept the log for N weeks, your list will include N dictionaries.

Define a function addDictN which takes a list of course log dictionaries and returns a dictionary which includes the total number of hours that you have studied on each day of the week throughout the semester. Your function definition should use the Python map and reduce functions as well as the addDict function you defined in part(a). You may need to define an additional helper function.

Example:

Assume you have recorded your log for 3 weeks only. [

{'355':{'Mon':3,'Wed':2,'Sat':2},'360':{'Mon':3,'Tue':2,'Wed':2,'Fri': 10},'321':{'Tue':2,'Wed':2,'Thu':3},'322':{'Tue':1,'Thu':5,'Sat':2}}, {'322':{'Mon':2},'360':{'Thu':2, 'Fri':5},'321':{'Mon':1, 'Sat':3}}, {'355':{'Sun':8},'360':{'Fri':5},'321':{'Mon':4},'322':{'Sat':3}}]

For the above dictionary addDictN will return:

{'Fri': 20,'Mon': 13,'Sat': 10,'Sun': 8, 'Thu': 10, 'Tue': 5, 'Wed': 6} (The items in the dictionary can have arbitrary order.)

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 Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions