Imagine you are writing a program and processes the raw data from a NASCAR (stock car) race from last weekend. The data is contained in a nested list, where each element is itself a list that contains the following: - A car number (as a string) - A driver's name (as a string) - List of lap names (as floats) Since many races are 200 or more laps, we have simplified the race data to only ten laps. Your job is to write a function named (find_loser) that takes the list of racers and determines the loser. The function should operate as follows: - Function is named find_loser - Function takes a single parameter, which is the list of data described above and demonstrated below. - The loser of the race is defined to be that race car/driver that has the highest overall cumulative race time for the 10 laps provided. - The function must return a tuple in the form of: (, , ). - The and must be string values. The must be a floating point value. If there is a tie of two or more losers with the same cumulative race times, the function should print an informative message and return an empty tuple (with no values). You can assume that car/driver element in the list contains a sublist with exactly 10 lap times that are floating point values. Do not assume a specific number of drivers/cars. Your function should work no matter how large the list of drivers/cars/times is.
PYTHON!!!
Imagine you are writing a program and processes the raw data from a NASCAR (stock car) race from last weekend. The data is contained in a nested list, where each element is itself a list that contains the following:
- A car number (as a string)
- A driver's name (as a string)
- List of lap names (as floats)
Since many races are 200 or more laps, we have simplified the race data to only ten laps.
Your job is to write a function named (find_loser) that takes the list of racers and determines the loser. The function should operate as follows:
- Function is named find_loser
- Function takes a single parameter, which is the list of data described above and demonstrated below.
- The loser of the race is defined to be that race car/driver that has the highest overall cumulative race time for the 10 laps provided.
- The function must return a tuple in the form of: (<car number>, <driver name>, <cumulative race time>).
- The <car number> and <driver name> must be string values. The <cumulative race time> must be a floating point value.
If there is a tie of two or more losers with the same cumulative race times, the function should print an informative message and return an empty tuple (with no values).
You can assume that car/driver element in the list contains a sublist with exactly 10 lap times that are floating point values.
Do not assume a specific number of drivers/cars. Your function should work no matter how large the list of drivers/cars/times is.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images