In tutorial 7 in the intro to programming with python series we covered python dictionaries.
The YouTube tutorial can be found here:
The exercise for this tutorial is to build a dictionary for class grades.
Initialize the grades dictionary with five names and marks (You pick names and marks)
Then write a code block that will ask the user to enter a name.
If name is found in the grades dictionary tell the user what his/her grade is. Then ask if they wish to change the grade. If answer is 'Yes' prompt them to enter a new grade and replace the old one in the dictionary.
If the name is NOT found in the grades dictionary prompt the user to enter a mark and add the name and associated mark to the grades dictionary.
Repeat this FIVE times (Copy and paste this code block)
When done tell the user what the grades dictionary looks like.
Here is a sample output from running the program.
Here is the program:
No comments:
Post a Comment