Expected results for a list-consuming function

A library is designing a function total_fine. Its signature and purpose statement are written first:

  • Signature: total_fine(days_late: list[int]) -> float
  • Purpose: consumes the number of days each borrowed book is late and produces the total fine in dollars. Each book is charged $0.25 per day late, but no single book is charged more than $5.00.

Before any code is written, work out the expected result of each example call below from the purpose statement alone. Give each answer in dollars to two decimal places.

  • total_fine([])
  • total_fine([20, 0, 21])
  • total_fine([30, 2])
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More The Design Recipe Questions: