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.
- Build a
feesdictionary mapping at least four service names to their cost (a number). - Make an
orderlist of the services one applicant needs — some of the keys fromfees. - Loop over the order, look each service's price up in
fees, print it, and add it to a runningtotalthat starts at 0. - 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 aKeyError. - 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: 105Where 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 totalHow we'll grade it
Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.
| Check | What we look for | Pt |
|---|---|---|
| It runs | Prints each item's price and a final total without crashing. | 1 |
| Prices come from the dictionary | Each cost is looked up in the `fees` dictionary by name — not retyped as a number in the order. | 1 |
| Total is accumulated | A `total` starts at 0 and grows in the loop. Change the order and the total still comes out right. | 1 |
| Reads well | Each item is shown with its price, and the total is labelled on its own line. | 1 |