Question: Please do in python Part II: Recursive Work Order Calculator (20 points) Write a recursive function rec.work.cost ) that takes two arguments, in this order:

Please do in python
 Please do in python Part II: Recursive Work Order Calculator (20

Part II: Recursive Work Order Calculator (20 points) Write a recursive function rec.work.cost ) that takes two arguments, in this order: 1. work.orders: a list of strings representing work orders 2. hourly.costs: a tuple of three integers representing the costs per hour to fix a pipe, window and sprin- kler, respectively Each work order in work.orders starts with a single digit and is followed by pipe, 'window' or' sprinkler' The digit indicates the number of hours that will be spent repairing the given item. For instance, ' 5sprinkler indicates that it wil take 5 hours to repair a particular sprinkler. For the moment, assuming that hourly.costs = (6, 2, 9). This means that it will cost 5 S9 = $45 to repair the sprinkler. In general, hourly costs will contain a different trio of values. The function recursively processes the entire list of work orders and returns the total cost of performing all the work orders One possible recursive algorithm you can consider implementing is this: if work orders is empty then otherwise return 0 let remaining_costs be the cost of completing all of the other work orders if work_orders[0 is for a pipe then otherwise, if work_orders [0 is for a window then otherwise, work_orders (0] must be for a sprinkler, so (i.e., work_orders1 and all later work orders) return (the cost to repair the pipe remaining.costs return (the cost to repair the window remaining costs) return (the cost to repair the sprinkler remaining costs) Note: Non-recursive solutions to the problem that use loops will not earn credit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!