wk02.p7Practice exerciseWeek 02 · Decisions and structureOpen · due this week

Application fee tally

Total a list of application fees with a loop. Practice the start-at-zero, add-one-at-a-time pattern you'll reuse all term for counting and averaging.

What you'll build

Total a list of application fees with a loop. Practice the start-at-zero, add-one-at-a-time pattern you'll reuse all term for counting and averaging.

Requirements

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

  1. Make a list of at least four application fees (numbers, in any currency you like).
  2. Start a total at 0, then use a for loop to add each fee on top, one at a time.
  3. After the loop, print the total clearly on its own line.
  4. Do not add the numbers by hand — the loop must do the totalling.
Bonus, if you're feeling brave
  • Also print the average — the total divided by len() of the list.
  • Print the most expensive fee. Start a highest at 0 and, inside the loop, replace it whenever you find a bigger one.

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
Total application fees: 275

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 tally

fees = [50, 75, 60, 90]   # TODO: make these your own
total = 0

# TODO: use a for loop to add each fee 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 runsStarts cleanly and prints a total without errors.1
Loop does the workA `total` starts at 0 and a `for` loop accumulates it — the answer is not hardcoded or added by hand.1
Total is correctThe printed total matches the sum of the list. Change a fee and it should still be right.1
Reads wellThe total is on its own line, labelled in plain English.1
Ready?
Hand it in
You can submit a draft and revise later if you're not done.
Begin submission →