Question: (a) Define the popular function to return a list of str (movie names) sorted by the number of reviewers, from highest to lowest, with equally
(a) Define the popular function to return a list of str (movie names) sorted by the number of reviewers, from highest to lowest, with equally popular movies listed alphabetically. If db is bound to the database above, calling popular (db) returns the list ['Pyscho', 'Amadeus', 'Jaws', 'Up'].
{'Psycho': {('Bob', 5), ('Carrie', 5), ('Alan', 1), ('Diane', 1)}, 'Amadeus': {('Carrie', 3), ('Diane', 3), ('Bob', 3)}, 'Up': {('Alan', 2), ('Diane', 5)}, 'Jaws': {('Carrie', 2), ('Alan', 5)} }
IN PYTHON!!!
(ONE RETURN STATEMENT ONLY- use lambda)
def popular (db : {str: {(str,int)}}) -> [str]:
#code here
pass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
