Drill

ProblemsPython › logistics

What does this parcel cost to send

easylogisticsPython

A courier prices every parcel as: the first five kilograms cost 300 (minor units) and each further kilogram adds 60.

parcel_cost(weight: int) → int

Solve it in the editor →

Where you start

def parcel_cost(weight: int) -> int:
    

Worked examples

CallResult
parcel_cost(3)300
parcel_cost(5)300
parcel_cost(6)360
parcel_cost(10)600

Hint

Subtract the free five, multiply what is left, and add the base.

Reference solution in Python
def parcel_cost(weight: int) -> int:
    if weight < 0:
        return 0
    return 300 + max(0, weight - 5) * 60

The same problem in another language

More logistics problems in Python