The lecture's Food class and buildMenu are given in the starter code. Write the function fractional_plan(foods, maxCost) that solves the continuous version of the meal problem: you may eat any fraction of a food, and eating a fraction of a food with value and calories earns value and costs calories.
Assume foods is a list of Food objects with distinct names and positive calories, and maxCost is a non-negative number. Return a dict that maps the name of each food eaten in a positive amount to the fraction eaten (a float, 1.0 for the whole food), for a plan whose total value is as large as possible without exceeding maxCost calories. Foods that are not eaten at all must not appear in the dict. Do not modify foods.
names = ['wine', 'beer', 'pizza', 'burger', 'fries', 'cola', 'apple', 'donut'] values = [89, 90, 95, 100, 90, 79, 50, 10] calories = [123, 154, 258, 354, 365, 150, 95, 195] foods = buildMenu(names, values, calories) plan = fractional_plan(foods, 750) print(sorted(plan)) # ['apple', 'beer', 'cola', 'pizza', 'wine'] print(plan['wine']) # 1.0 print(round(plan['pizza'], 4)) # 0.8837 print(fractional_plan(foods, 0)) # {}