Question: Define a function named get_average(a_dict) which takes a dictionary as a parameter. The function returns a new dictionary where the keys are the same keys

Define a function named get_average(a_dict) which takes a dictionary as a parameter. The function returns a new dictionary where the keys are the same keys as the parameter dictionary but the values are the average of the list of numbers of the corresponding key. Round the average value to 2 decimal places.

For example:

Test Result
a_dict = { 'l':[5], 's':[8], 't':[10, 3, 8, 5] } result = get_average(a_dict) for key in sorted(result.keys()): print(key, ':', result[key])
l : 5.0 s : 8.0 t : 6.5 

Answer:(penalty regime: 0 %)

1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To define the getaverageadict function follow these steps Step 1 Set Up the Function Start by defini... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!