Write a program in file p1.py that does the following a) Displays a ranking (des
ID: 3910738 • Letter: W
Question
Write a program in file p1.py that does the following a) Displays a ranking (descending) of the movie directors with the most movies in the top rated list. Print only the top 5 directors, with a proper title above b) Displays a ranking (descending) of the directors with the most movies in the top grossing list. Print only the top 5 directors, with a proper title above c) Displays a ranking (descending) of the actors with the most movie credits from the top rated list. Print only the top 5 actors, with a proper title above d) Displays a ranking (descending) with the actors who brought in the most box office money, based on the top grossing movie list. For a movie with gross ticket sales amount s, the 5 actors on the cast list will split amount s in the following way: 1 (first billed) 2 Actor # $$ per actor 16*s/31 Print only the top 5 actor pairs, with a proper title above. 3 4 8#5/31 4*S/312*s/31 s/31 EXTRA CREDIT 5 points e) Displays in order the top 10 "grossing actor pairs" that played together in the same movie. The total amount (used for sorting) for a pair of actors is the sum of the gross revenue allocated to each actor with the scheme in the table above, but computed only for movies where the two actors played together. We can expect Harrison Ford and Mark Hamill to be near the top, since they were together in the original Star Wars movies Take a screenshot of the program's output (a-d + e) and insert it in the h3.doc file right after the code from file p1.py Design and Implementation Requirements To get credit for this problem, follow these requirements: a) Apply the top-down design methodology. Seek commonality among the tasks listed above. Break the problems into subproblems divide&conquer-style;, then write functions dealing with the subproblems b) Compute and use 3 dictionaries with the key in the form of a tuple (movie_name, movie_year) for storing movie cast information, ratings info, and gross info, respectively. We need to include the year as part of the key since it's possible in principle to get two different movies with the same title, but it is less likely to be from the same year. Use a dictionary for storing actor information with the key being the actor name and value being the list of (movie_name, movie_year) tuples for movies in which they played, and any other data needed, such as gross allocated (per the table above). Store multiple values for one entry in a tuple or list c) Write docstrings for functions and comment your code following the guidelines from the textbook. Follow the Python coding style rulesExplanation / Answer
from collections import namedtuple Movie = namedtuple("Movie", ["name", "year"]) MovieInfo = namedtuple("MovieInfo", ["cast_list", "director_name","rating","gross_sale"]) ActorInfo = namedtuple("ActorInfo",["movie","credits","earning"]) class MovieUtility: movieDict = {} actorsDict = {} def enterMovieDetails(self): """Let user add movies List and internally creates movieDict and actorsDict""" wantToEnter = input("Want to enter Movie Name and Details (Y/N): ") while(wantToEnter == 'Y'): movie_name = input("Movie Name : ") movie_year = input("Release year : ") movie_rating = input("Movie Ratings : ") movie_gross_sale = input("Gross Sale : ") directors_name = input("Movie Director's Name : ") number_of_cast = input("Number of Cast : ") actors_list = [] m= Movie(name = movie_name,year= movie_year) for i in range(1,int(number_of_cast)+1): actors_name = input("Enter Cast's Name : ") actors_list.append(actors_name) actors_movie_credits = input("Enter Cast's movie credits for this movie : ") actors_earnings = (int(movie_gross_sale) * (2Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.