Drill

ProblemsPython › billing

Compute the late payment fee

easybillingPython

A billing system charges a fixed fee for the first overdue day and a smaller increment for each additional day.

late_fee(days_late: int) → int

Solve it in the editor →

Where you start

def late_fee(days_late: int) -> int:
    

Worked examples

CallResult
late_fee(1)2500
late_fee(2)3000
late_fee(5)4500
late_fee(0)0

Hint

Subtract one from the count, multiply the increment, and add the base — but only when positive.

Reference solution in Python
def late_fee(days_late: int) -> int:
    if days_late <= 0:
        return 0
    return 2500 + (days_late - 1) * 500

The same problem in another language

More billing problems in Python