Preset Shipping Calculators with partial()

Hard ⏱ 18 min 24% acceptance ★★★★☆ 4.2
Given shipping_cost(rate_per_kg, fixed_fee, weight), use functools.partial to build standard = partial(...) (rate 40, fee 50) and express = partial(...) (rate 90, fee 100) inside a function make_calculators() that returns both as a tuple. Each returned callable takes only weight.

Examples

Example 1
Input
std, exp = make_calculators(); std(2)
Output
130
Explanation

40×2 + 50 = 130 for standard shipping of 2 kg.

Constraints

  • Use functools.partial, not lambdas.
  • Return (standard, express).

Topics

Lambda & Functionalfunctools.partial

Companies

FedExDelhiveryAmazon

Hints

Hint 1

partial(f, a, b) pre-fills the leading positional args.

Hint 2

Order of parameters in shipping_cost matters.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.