Capstone project

Project: a time-budgeted study planner

Lesson 20 of 20 · 25 min · Module 6: Reliable inputs & practical reports

Turn a CSV list into a realistic little study plan. Read imperfect input, apply a clear ordering rule, and choose sessions that fit the remaining time.

Start this lesson →

Free. No installation: you write and run the code in your browser, and it is checked automatically.

By the end, you’ll be able to…

  • Build a multi-stage program from a brief
  • Keep selection inside an explicit budget

The idea

This is a greedy planner: visit short sessions first, then include a session when it fits. It follows the stated rule; it does not claim to optimize every possible learning objective.

# Plan before coding:
# parse → validate → sort by (minutes, title) → fit sessions → report

01Separate format errors from planning

Clean every row before selection. A malformed duration should not abort the entire plan or become an accidental zero-minute session.

02Explain the chosen strategy

Sort by duration, then title. The same input and budget should lead to the same selection order, including ties.

03Check the accounting invariant

After every included session, total must be no greater than budget. At the end, total plus remaining must equal the original budget.

Your project brief

Write build_plan(text, budget). CSV headers are title,minutes. Skip empty titles and invalid or nonpositive integer minutes. Strip titles, sort by minutes then title, and include each session if it fits the remaining budget. Return {"titles": [...], "minutes": total, "remaining": budget-total}. budget is a nonnegative integer. Handle quoted commas and empty input.

What the checks look for

  • Chooses short sessions within a shared budget
  • Uses cleaned titles to break a tie
  • Rejects invalid rows and preserves quoted titles
  • Handles an empty file and zero budget
  • Includes an exact fit and skips oversized sessions
Try it in the editor →

Take this with you

A useful report explains both what was selected and what capacity remains.

Go a little further

Add a rejected-row report and an optional maximum number of selected sessions.

Learn Python Foundations for free

20 short lessons with real code and instant checks.

See the whole course →