Flow controls: Conditions · 21 / 22 Exercise Medium

Shipping rate by brackets

Objective

The price of a shipment depends on the bracket in which the weight of the package falls. The conditions are evaluated in order, so each elif is only reached if the previous ones failed.

Instructions

  • Read the weight in kilos (decimal).
  • Up to 1 kg (inclusive) costs 5.00; up to 5 kg, 8.50; up to 20 kg, 15.00; above 20 kg it costs 15.00 plus 0.75 for each kilo over 20 (decimals are charged too).
  • Show Price: x.xx with two decimals.
Input
3.2
Output
Price: 8.50

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise