Question: python 3 Write a function cafe.day that which takes one argument, orders, which is a list of drink orders for the day at a caf.

python 3

python 3 Write a function cafe.day that which takes one argument, orders,

Write a function cafe.day that which takes one argument, orders, which is a list of drink orders for the day at a caf. The list orders contains one or more sub-lists, in which each sub-list represents a particular drink order. In each sub-list, there are four elements, in this order 1. A string that indicates the customer's membership, which will be one of these three categories: Platinum membership is represented by the letter 'P eGold membership is represented by the letter G e Silver membership is represented by the letter S' 2. An integer that represents the number of large drinks for the particular order. 3. An integer that represents the number of medium drinks for the particular order. 4. An integer that represents the number of small drinks for the particular order. Your function should process all orders, then return a floating-point number that represents the revenue generated for the day in dollars. Don't round the retun value! The prices for different sizes are as follows: Drink Size Price $3.50 Medium $2.50 $1.25 Large ma In addition, there will be different privileges depending on different memberships, as described below: Membership Privilege Platinum If the customer purchases 3 or more large drinks, OR 4 or more medium drinks, then he/she gets at most 3 free small drinks. If the customer purchases at least 10 drinks (in any combination of small, medium and large), then he/she gets a 20% discount. The customer receives 2% off of total Gold regardless of number of drinks ordered. ver Invalid values: Your function should be able to handle invalid values outlined below. In these cases, skip the entire drink order and continue to the next one. Valid drink orders have the following characteristics: . Each sub-list has exactly four values. . The first element in the sub-list, which is the membership, is one of the three strings P, 'G' or'S' (all lowercase letters are invalid) . The number of drinks for all three sizes is greater than or equal to zero. If the orders list is empty, the function should simply return 0.0 Examples: orders! orde r s2 orde r s 3 [[,P', [[,B', [["G, , 5, 1, 4, 0, 2, 3, 411 3], 2], = ['P', [,S', 5, 0, 0, 0, 4], ["G, , 4, 4, 2]] 10], ['P', 1, 4, 311 = = Function Call cafe.day (orders1) 18.75 cafe.day (orders2) 39.95 cafe.day (orders 3) 49.75 Return Value

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!