Answer:
I am writing a Python program:
This is the find_max_sales
def find_max_sales(tuple_list): #method that takes a list of tuples as parameter and returns the movie name which had the most sales
maximum=0 #stores the maximum of the ticket sales
name="" #stores the name of the movie with maximum sales
for tuple in tuple_list: # iterates through each tuple of the tuple list
[movie, sale]= tuple #tuple has two items i.e. movie contains name of the movies and sale holds the total ticket sale of the movie
if sale>maximum: #if the sale value of a tuple is greater than that of maximum sale value
maximum=sale #assigns the maximum of sales to maximum variable
name=movie # assigns the movie name which had most sales to name variable
return name #returns the movie name that had the most sales and not the full tuple
#Below is the list of list of movies. This list is passed to the find_max_sales method which returns the movies name from the list that had the most sales.
movie_list = [("Finding Dory", 486), ("Captain America: Civil War", 408), ("Deadpool", 363), ("Zootopia", 341), ("Rogue One", 529), ("The Secret Life of Pets", 368), ("Batman v Superman", 330), ("Sing", 268), ("Squad", 325), ("The Jungle Book", 364)]
print(find_max_sales(movie_list))
Step-by-step explanation:
The program has a method find_max_sales that has one parameter tuple_list which is a list of tuples. Each tuple i.e. tuple has two items a movie which is a string and sale which is an integer. The movie represents the name of a movie, and the sales represents that movie's total ticket sales The function has a loop that iterates through each tuple tuple of the list tuple_list. Variable maximum holds the value of the maximum sales. The if condition checks if the value of tuple sale is greater than that stored in maximum, at each iteration. If the condition evaluates to true then that sale tuple value is assigned to maximum variable so that the maximum holds the maximum of the ticket sales. The name variable holds the name of the movie corresponding to the maximum sale tuple value. The method returns the movie name from the tuple_list that has the most sales.
For example in the above given movie_list , the maximum of sale is of the movie Rogue One. When the method is called it returns the movie name and not the full tuple so the output of the above program is:
Rogue One