Question
Help. Please use the python code to do it. Thank you so much. Given three unsorted lists, a name list, an Exam1 score list, and
Help. Please use the python code to do it. Thank you so much.
Given three unsorted lists, a name list, an Exam1 score list, and an Exam2 score list, e.g.
nameLst = [Betty, Andrew, Zach, Cathy, Jay, Kevin, Cassie, Matt, Jamie, Xavier, Peter, John, Jamie, Joe, Ellen, Nancy, Jay, Bryce, Gordon, Gee]
score1 = [50, 45, 48, 48, 46, 49, 35, 38, 42, 50, 44, 37, 35, 32, 48, 32, 44, 45, 41, 46]
score2 = [35, 48, 50, 37, 45, 41, 47, 50, 47, 41, 47, 48, 46, 49, 41, 38, 46, 42, 33, 39]
Write the following functions:
- def makeLst (aNameLst, e1ScoreLst, e2ScoreLst) :
#the function will return a list of tuples as in the following form
#[(Betty, (50,35)), (Andrew, (45,48)), (Zach, (48,50)), (Cathy, (48,37)), ]
- def personalAverage(aList) :
#aList in the form of [(Betty, (50,35)), (Andrew, (45,48)), ]
#returns another class list in the form of [(Betty, 42.5), (Andrew, 46.5), ]
- def sortByName (bList) :
#bList in the form of [(Betty, 42.5), (Andrew, 46.5), ]
#returns another class list in the form of [(Andrew, 46.5), (Betty, 42.5), ]
#i.e. sort by name in ascending order
#optional: if name is same, the one with higher score comes first (otherwise if name same, scores could be in any order.)
#note: you may use predefined sorted() or sort() in function body, same for (4) & (5).
- def sortByAveScore (bList) :
#bList in the form of [(Betty, 42.5), (Andrew, 46.5), ]
#returns another class list in the form of [(Zach, 48.0), (Andrew, 46.5), ]
#i.e. sort by average score in descending order
#optional: if score same, order names in alphabetical order (otherwise if score same names could be in any order.)
- def classMean(cList1, cList2) :
#cList1 and cList2 in the form of score1 or score2
#returns exam1MeanScore and exam2MeanScore for the class
#note: you may use functions in statistics module, same for (6).
- def classStdDev (cList1, cList2) :
#similar to (5) but returns the standard deviation for Exam1 and Exam2 respectively
- Write a main function that calls each of the above functions on the given data (you may initialize data in the code) to run.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started