#226 · Python Basics · Beginner · 30 XP · about 5 min
An online shop charges for delivery by the weight of the parcel. Write shipping_cost(weight, order_total) that returns the delivery cost in dollars as a whole number. weight is in kilograms and order_total in dollars, and both can have decimals.
Orders worth 50 dollars or more ship free, except heavy parcels: anything over 20 kg always costs 30 dollars.
shipping_cost(0.5, 20) # returns 4 shipping_cost(12, 30) # returns 15 shipping_cost(3, 75) # returns 0 shipping_cost(25, 200) # returns 30
weight is always more than 0, and order_total is never negative.
First solves only, ranked by stars and then time.