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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started