wk02.p16Practice exerciseWeek 02 · Organizing dataOpen · due this week

Scholarship records

Keep several scholarships as a list of dictionaries, then loop through to print them and filter the ones still open. This is the shape of real data — one record per dictionary, all of them in one list.

What you'll build

Keep several scholarships as a list of dictionaries, then loop through to print them and filter the ones still open. This is the shape of real data — one record per dictionary, all of them in one list.

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 scholarships. Each one is a dictionary with the keys name, country, and open (a True/False).
  2. Loop over the list and print each scholarship's name and country on its own line.
  3. Build a second list of just the names where open is True, using append inside the loop.
  4. After the loop, print how many are open out of the total using len().
Bonus, if you're feeling brave
  • Add a min_gpa field to each record, ask the user for their GPA, and list only the scholarships they qualify for.
  • Ask the user for a country and print only the scholarships based there.

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
Chevening UK
DAAD Germany
Fulbright USA
Mastercard Foundation Canada
3 of 4 still open.

Where to start

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

# Scholarship records

scholarships = [
    {"name": "Chevening", "country": "UK", "open": True},
    {"name": "DAAD", "country": "Germany", "open": True},
    {"name": "Fulbright", "country": "USA", "open": False},
    # TODO: add at least one more
]

open_now = []

# TODO: loop over scholarships, print each name and country,
#       and append the name to open_now when it's open

# TODO: print how many are open out of len(scholarships)

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 every scholarship and the open count without crashing.1
List of dictionariesData is a list where each item is a dictionary with named fields — not parallel lists, not one flat dictionary.1
Correct field accessInside the loop the code reaches one record's fields with `s["name"]`, `s["country"]`, `s["open"]`.1
Filter and countThe open list holds only the open ones, and the final count matches, reported out of `len()` of the full list.1
Ready?
Hand it in
You can submit a draft and revise later if you're not done.
Begin submission →