loyalty_price(price, tier="Bronze", *, extra_off=0) that applies a percentage discount based on tier ("Bronze": 0%, "Silver": 5%, "Gold": 10%, "Platinum": 15%), then subtracts an additional flat extra_off amount (keyword-only, defaulting to 0), and returns the final price rounded to 2 decimal places. The final price must never go below 0.loyalty_price(1000, "Gold")
900.0
10% off 1000 is 900, no extra_off supplied.
loyalty_price(1000, "Silver", extra_off=100)
850.0
5% off 1000 = 950, then minus 100 extra_off = 850.0.
loyalty_price(50, "Bronze", extra_off=1000)
0.0
The subtraction would go negative, so it is clamped to 0.0.
Use a dict mapping tier names to discount percentages.
Apply max(0, computed_price) before rounding, or round then clamp — either order works here since extra_off and rates are non-negative.