question 134 Built-ins & Sorting · easy
Order total with free shipping
Checkout adds a flat shipping charge, but orders whose goods total 50 or more ship free. Compute what the customer pays.
Function
order_total(lines, shipping)linesdictionaries with
qty and priceReturnsthe goods total (quantity × price, added up) plus
shipping, or just the goods total when it is 50 or moreRulesan empty basket costs only the shipping
Examples
callorder_total([{'qty': 2, 'price': 7.5}, {'qty': 1, 'price': 31}], 4.99)returns50.99
callorder_total([{'qty': 1, 'price': 171.25}], 4.99)returns171.25
callorder_total([], 4.99)returns4.99