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.
- Make a list of at least four scholarships. Each one is a dictionary with the keys
name,country, andopen(aTrue/False). - Loop over the list and print each scholarship's name and country on its own line.
- Build a second list of just the names where
openisTrue, usingappendinside the loop. - After the loop, print how many are open out of the total using
len().
- Add a
min_gpafield 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.
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.
| Check | What we look for | Pt |
|---|---|---|
| It runs | Prints every scholarship and the open count without crashing. | 1 |
| List of dictionaries | Data is a list where each item is a dictionary with named fields — not parallel lists, not one flat dictionary. | 1 |
| Correct field access | Inside the loop the code reaches one record's fields with `s["name"]`, `s["country"]`, `s["open"]`. | 1 |
| Filter and count | The open list holds only the open ones, and the final count matches, reported out of `len()` of the full list. | 1 |