Problem 137074 · easy · Level 01 Prerequisites & Setup

Overdue Library Fine

conditionals · arithmetic

A library charges for late books. Write library_fine(days_late) that returns the fine as a float:

  • not late (0 or fewer days): 0.0
  • 0.25 per day for each of the first 7 days
  • 0.50 per day for every day after the seventh
  • the fine never exceeds 10.0

Examples

Input:  days_late = 0
Output: 0.0

Input:  days_late = 3
Output: 0.75

Input:  days_late = 10
Output: 3.25
Explanation: 7 * 0.25 + 3 * 0.50 = 1.75 + 1.50.

Constraints

  • -30 <= days_late <= 10000 (integer)

Goals

  • Combine a flat per-day rate with a higher rate after a threshold
  • Apply a maximum with an if
Starting Python…