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
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