EasyFunctionsNot started

Parcel cost function

A neighbourhood courier charges 40 base units, plus 8 per whole kilogram and 2 per kilometre. Read weight and distance, define a function named delivery_cost, and print the calculated charge.

Input

One line containing two integers: weight in kilograms and distance in kilometres.

Output

One integer: the total delivery charge.

Example 1

Input

3 12

Output

88

40 + (3 × 8) + (12 × 2) equals 88.

Constraints

  • 1 <= weight <= 100
  • 1 <= distance <= 1000

Hints

Hint 1 of 3

A function sends a value back with return.

Hint 2 of 3

Calculate each variable part before adding the base charge.

Hint 3 of 3

Return 40 + weight * 8 + distance * 2.

Solution

Show a reference solution and explanation
 Python · reference solution
def delivery_cost(weight, distance):
    return 40 + weight * 8 + distance * 2

weight, distance = map(int, input().split())
print(delivery_cost(weight, distance))

Why it works

The named function separates the pricing rule from input and output. Its parameters make the calculation reusable, and returning the number lets the caller decide how to display or further process it.

Lesson for this exercise: Functions in Python

Your program
def delivery_cost(weight, distance):
    # return the calculated charge
    pass

weight, distance = map(int, input().split())
print(delivery_cost(weight, distance))

Tests: 3 cases including the examples. Passing every test marks the exercise solved in this browser.

How this page was checked. Every program on it was run with CPython 3.11 at build time; runs in your browser on CPython 3.14 (Pyodide) by the publishing checks, and the output shown is what it printed. The Run buttons execute the same code on your device; nothing you type is sent anywhere.