runtime
134 / 500
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.

Functionorder_total(lines, shipping)
linesdictionaries with qty and price
Returnsthe goods total (quantity × price, added up) plus shipping, or just the goods total when it is 50 or more
Rulesan 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

Loading your progress…

Order total with free shipping — Python practice · Runtime