Question: PYTHON 3 Netflix stores a database that we can represent as a dict, whose keys are movie titles like 'Pscyho' (str); associated with each title

PYTHON 3

Netflix stores a database that we can represent as a dict, whose keys are movie titles like 'Pscyho' (str); associated with each title is a set of 2-tuples. Each 2-tuple specifies the name of a reviewer (str) followed by a review score (int: a number 0-5); for example ('Alice', 5). A simple/small database can look like

 {'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)} }

Define the score_dict function to return a dict whose keys are the scores, where each reviewer is associated with a set of 2-tuples (movie names and their reviewer). If db is bound to the database above, calling score_dict (db) returns the dict

{1: {('Psycho', 'Diane'), ('Psycho', 'Alan')}, 2: {('Jaws', 'Carrie'), ('Up', 'Alan')}, 3: {('Amadeus', 'Diane'), ('Amadeus', 'Bob'), ('Amadeus', 'Carrie')}, 5: {('Jaws', 'Alan'), ('Up', 'Diane'), ('Psycho', 'Carrie'), ('Psycho', 'Bob')} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!