Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions