Question: Could Someone pls help me write this function in python? Function name: average_rating Parameters : a dictionary named movies_dict {keys are the names of movies
Could Someone pls help me write this function in python?
Function name: average_rating
Parameters: a dictionary named movies_dict {keys are the names of movies (string): values are a list of integer ratings from zero to ten (list of ints)} Returns: a dictionary {keys are names of movies (string): values are that shows average rating (float)}
Description: Write a function that takes in a dictionary and returns a dictionary. The function will take in a dictionary, movies_dict, where the key will be a string that represents the name of some movie and the value will be a list of integers representing ratings on a ten-point scale for that movie. The function should take this dictionary and make a new dictionary where the keys will be strings of the movie name and the values will be the average rating for that movie (rounded to 2 decimal points).
Notes:
Remember to round the average rating of each movie to two decimal points!
Every movie included in movies_dict will have at least one rating.
Every rating is out of ten.
If you print out your returned dictionary the order of the artists may be different from ours, whats important is that each artist (key) is correctly matched to their price totals (value).
Test Cases:
>>> movies_dict = {Back to the Future : [8, 7, 9, 10], Independence Day :
[8, 7, 5, 10, 10], Men in Black : [7, 6, 9], Rush Hour : [8, 9, 10, 10]}
>>> test1 = average_rating(movies_dict)
>>> print(test1)
{'Back to the Future': 8.5, 'Independence Day': 8.0, 'Men in Black': 7.33,
'Rush Hour': 9.25}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
