Question: v Part 4: Vacation Planner (8 points) Complete the function nyc_vacation, which takes two arguments, in the following order: 1. prices: A list of integers



v Part 4: Vacation Planner (8 points) Complete the function nyc_vacation, which takes two arguments, in the following order: 1. prices: A list of integers that serves as a price list. This list always has three positive integers, with each element representing the price of a particular cost of vacationing in NYC, and always in this order: 0 The rst element of the list (prices [ 0] ) represents the cost of one tour around the city. 0 The second element of the list (prices [ 1] ) represents the cost to see one Broadway 'show' . o The third element of the list (prices [ 2] ) represents the cost of one 'museum' ticket. 2. activity_1ist2 A list of strings that represents a sequence of activities in NYC. Each item is always one of 'tour' , 'show' , or 'museum' . When an item appears multiple times, it means that multiple outings of that type were purchased. You may assumed that the list will not contains any strings other than these three. The function calculates and returns the oating-point total cost of the activity list. However, there are a few discounts that might apply: 1. If three or more tours are taken, apply a 12% discount to the total cost of all tours. This discount can be used in addition to the entire activity list discount, described next. 2. Only one of the following discounts to the entire cost might apply: a. If exactly two Broadway shows are seen, apply a 10% discount to the total cost of the entire activity list. This discount applies to the total cost after discount #1 is considered. b. If three or more Broadway shows are seen, apply a 25% discount to the total cost of the entire activity list. This discount applies to the total cost after discount #1 is considered. Again, only one of discounts 2(a) or 2(b) can be applied, not both. An Example in Detail: Function call: nyc_vacation ( [75, 150, 40], ['tour' , 'show' , 'museum', 'museum' , 'show' , 'tour', 'tour' ]) Sorting it out a little bit, we have: . 'tour' x 3, at $75 each. We took three or more tours, so we will have a 12% discount on the tours. 'show' x 2, at $150 each. We saw exactly two Broadway shows, so we will have a 10% discount on the entire list of activities. 'museum' x 2, at $40 each. Calculate the total price before the 10% total discount is applied: (75 X 3) X 0.88 + (150 x 2) + (40 x 2) = 578.0 Now we can apply the 10% total discount, and get our final return result: 578.0 X 0.9 = 520.2\f
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
