Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Once you tested your function for a single list, you can re - use it to solve the original problem. This time you are given

Once you tested your function for a single list, you can re-use it to solve the original problem. This time you are given a people list of non-empty lists, where each list represents different bridges and a number of people crossed it. You are also given a list of names of the bridges corresponding to the list of people. Write a function that outputs a name of the bridge with the highest average (as described above). You can assume that the lengths of both lists are the same. Special instructions: If there is a tie, return the highest average that appears first. In case of an empty list, return No bridges to choose from. If all the bridges have average rating 0.0, treat 0.0 as the best rating and return the first route. Hints: You should reuse the function from Question 4.1 max() will be helpful The lists .index() might be helpful (look up the documentation!) The function should work with any number of bridges. def best_average_bridge(people, bridges): """ Finds the best bridge name based on the average --->>> ratings =[[1,10,5],[4,6,9]]>>> names =["flames", "river"]>>> best_average_bridge(ratings, names) 'river' >>> ratings =[[6,10,5,3,8],[10,10,9],[6,6,90]]>>> names =["flames", "flower", "river"]>>> best_average_bridge(ratings, names) 'flower' >>> ratings =[[],[],[]]>>> names =["flames", "flower", "river"]>>> best_average_bridge(ratings, names) 'flames' >>> best_average_bridge([],[])'No bridges to choose from' """

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions

Question

describe the main employment rights as stated in the law

Answered: 1 week ago