Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
549 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | Python (34 exercises) |
Topic ==> | Dictionaries (2 exercises) |
Level ==> | Harder than average |
Subject ==> | Python training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
The CSV file in the above folder contains a list of the Formula 1 Grand Prix events for the 2023 season:
For those unfamiliar with the "sport", Formula 1 involves overpaid men driving noisily and pointlessly round a track burning up precious fossil fuels, while spectators pay to watch in the hope of seeing a crash. Or at least, that's one interpretation ...
Write a Python program called Race cards.py which reads the race event lines into a dictionary, using the event name as the key (one is shown highlighted in the screenshot), and storing the other information in a tuple or list. Test whether you've done this correctly by looping over the dictionary items showing their values using syntax like this:
for key, value in race_events.items():
This should give something like this:
Who knows what the weird opening character is!
Now create a variable to hold a test Grand Prix name and see if it's in your list (the code below is shown to start you off):
# test whether this has worked
input_name = "Australian GP"
if input_name in race_events:
If the item is in the dictionary you should show its details; otherwise, you should show a suitable message. Here's what you might see for the test input name shown above:
By contrast, if you type in a non-existent grand prix event name as your input, you should see something like this:
When everything is working, save your program and close it down.
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.