Question: PYTHON Question5: You have been given the following lists of students and their test scores: names = ['joe', 'tom', 'bard', 'sue', 'sally'] scores = [10,
PYTHON
Question5: You have been given the following lists of students and their test scores:
names = ['joe', 'tom', 'bard', 'sue', 'sally']
scores = [10, 23, 13, 18, 12]
Given the lists from question5 and the following definition of the function, makeDictionary:
def makeDictionary(names,scores):
scoreDictionary = { }
for index in range(len(names)):
scoreDictionary[names[index]] = scores[index]
return scoreDictionary
- Using scoreDict, find the score for 'bard'.
- Add a score of 19 for 'john'.
- Create a sorted list of all the scores in scoreDict.
- Calculate the average of all the scores in scoreDict.
- Update the score for 'sally' to be 13.
- Tom has just dropped this class. Delete 'tom' and his score from scoreDict.
- Print a table of students and their scores with the students listed in alphabetical order.
- Write a function called getScore that takes a name and a dictionary as parameters and returns the score for that name if it is in the dictionary. If the name is not in the dictionary, print an error message and return -1.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
