AssignmentsWeek 02 · Organizing dataApplication fee calculator
wk02.p18Practice exerciseWeek 02 · Organizing dataOpen · due this week

Application fee calculator

Keep a price list in a dictionary, then add up the cost of one applicant's order. Dictionary lookup meets the start-at-zero totalling pattern.

What you'll build

Keep a price list in a dictionary, then add up the cost of one applicant's order. Dictionary lookup meets the start-at-zero totalling pattern.

Requirements

The must-do parts. If any are missing, we'll ask you to take another pass.

  1. Build a fees dictionary mapping at least four service names to their cost (a number).
  2. Make an order list of the services one applicant needs — some of the keys from fees.
  3. Loop over the order, look each service's price up in fees, print it, and add it to a running total that starts at 0.
  4. After the loop, print the total cost on its own line.
Bonus, if you're feeling brave
  • Use .get(service, 0) for the lookup so an unknown service is skipped (counts as 0) instead of crashing with a KeyError.
  • Apply a 10% discount when the order has four or more items, and show the discounted total.

Examples

What your program should look like when it runs. Lines starting with $ are typed by you; the rest is your program.

Example cell runs
application: 50
transcript: 30
courier: 25
Total: 105

Where to start

Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.

# Application fee calculator

fees = {
    "application": 50,
    "transcript": 30,
    "english test": 200,
    "courier": 25,
}

order = ["application", "transcript", "courier"]
total = 0

# TODO: loop over order, look up each price in fees,
#       print it, and add it to total

# TODO: print the total

How we'll grade it

Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.

CheckWhat we look forPt
It runsPrints each item's price and a final total without crashing.1
Prices come from the dictionaryEach cost is looked up in the `fees` dictionary by name — not retyped as a number in the order.1
Total is accumulatedA `total` starts at 0 and grows in the loop. Change the order and the total still comes out right.1
Reads wellEach item is shown with its price, and the total is labelled on its own line.1
Ready?
Hand it in
You can submit a draft and revise later if you're not done.
Begin submission →