The first four functions you are to implement are helper functions, meaning they are written to help you implement other functions. You can use these functions in the 5th and 6th function. It is suggested that you implment these four first. The following are the 4 helper functions you are to implement.
All four functions should take an argument calledmovie
that is a list that contains the the movie’s corresponding values in the following order: [movie name, gross earning, year, rating out of 10, number of ratings]. 1.get_name(movie)
.{python}
The
get_name
function should return the name of the provided list.
get_gross(movie)
.{python}
Theget_gross
function should return the gross earnings of the provided list.
get_rating(movie)
.{python}
Theget_rating
function should return the rating of the provided list.
get_num_ratings(movie)
.{python}
Theget_num_ratings
function should return the number of ratings of the provided list.
3.2better_movies(movie_name, lst)
.{python}
Themovie_name
is a string whose value is corresponding to a movie_name inlst
.
Thelst
is a list of lists, where the lists inside the list comprises of a movie’s information in the following order: [movie name, gross earning, year, rating out of 10, number of ratings].
Thebetter_movies
function should take the providedmovie_name
and search through the providedlst
and return a list of all movies’ information that have a higher rating than that ofmovie_name
. Assume that themovie_name
given will always be in the providedlst
.
3.3average(category, lst)
.{python}
Thecategory
is a string whose value will either be “rating”, “gross’, or”number of ratings". We will not provide any other string values than those three to this function.
Thelst
is a list of lists, where the lists inside the list comprises of a movie’s information in the following order: [movie name, gross earning, year, rating out of 10, number of ratings].
Theaverage
function will return the average for all movies based on the provided category. For example, ifcategory
is equal to “rating”, this function will return the average of all ratings inlst
.
3.4Style matters
In addition to functional correctness, some points will be reserved for
having good variable names
having meaningful docstrings for all functions you write