14 lines
496 B
Python
14 lines
496 B
Python
"""Order pricing helpers for the Hermes code-repair demo."""
|
|
|
|
|
|
def apply_discount(subtotal: float, percent: float) -> float:
|
|
"""Return the subtotal reduced by a whole-number discount percent.
|
|
|
|
Inputs: the order subtotal and a discount percent between 0 and 100.
|
|
Outputs: the discounted total, rounded to two decimal places.
|
|
"""
|
|
|
|
if percent < 0 or percent > 100:
|
|
raise ValueError("percent must be between 0 and 100")
|
|
return round(subtotal * (1 - percent / 100), 2)
|