Question: Allowed Things: The + , + = , and all numeric operators in / not in and del operator break and continue str ( )

Allowed Things:
The +,+=, and all numeric operators
in/not in and del operator
break and continue
str(), int(), float(), range(), len(), append(), round(), and get() functions.
List slicing only for recursive functions (the last two functions), but not for the rest. Disallowed Things:
To import anything.
To use list slicing.
To use any string method.
To use lambda expressions class.
Anything not mentioned in the allowed items above.
Use the global keyword, nor should you have any global variables (in other words, do not create any variables outside if a function definition)
Hard coding
part 4:
def finalGrade(names, PAs, exams):
Description: This function takes a list of students' names, a tuple containing the list of PA grades and the number of grades to drop, and a list of dictionaries with exam scores for each student. It calculates the final grade for each student and stores it in a dictionary where the keys are the students' names and the values are their final grades. This function MUST be implemented by calling the weighted_PAs and weighted_exams functions. The final grade is the sum of the weighted exam scores (60% in total) and the weighted PAs (40% in total).
4 Parameters: names, a list of strings indicating the students' names. PAs, a tuple of lists, where each list contains the list of grades earned for each PA, followed by the number of grades that need to be dropped for a student. exams, a list of dictionaries, where each dictionary contains the exam scores each student obtained. The keys of this dictionary are always 'fe','mt1', and 'mt2', but they may appear in different orders in the dictionary
Return value: A dictionary that shows the names of students as keys and their final scores as values.
Assumptions: All the PAs gardes are between 0 and 50 and all the exam scores are between 0 to 100(inclusively). The lengths of names, PAs, and exams are all equal. Examples: finalGrade(['John'],([[50,48,25,45]],),[{'fe' : 100,'mt1': 90,'mt2': 100}])-->{'John': 92.1}
finalGrade (['John', 'Mason'],([[5,8,0],2],[[50,30,40,45],2]),[{'fe' : 100,'mt1': 90},{'mt1':10,'fe':50,'mt2':80}])-->{'John': 64.9, 'Mason': 66.5}
finalGrade (['Rose', 'Tom', 'Paul'],([[50,12,40],1],[[10,10,30,30,40],2],[[40,14,15,50,50,36],3]),[{'fe' : 100},{'mt1': 100,'mt2':50},{}])-->{'Rose': 96.0, 'Tom': 49.17, 'Paul': 37.33}
Do the 4 part I have already written part 2 and 3 here is the code:
# Part 2
def weighted_PAs(grades, drop=0):
for _ in range(drop):
if grades:
l_grades = grades[0]
l_index =0
for i in range(1, len(grades)):
if grades[i]< l_grades:
l_grades = grades[i]
l_index = i
grades.pop(l_index)
if len(grades)==0:
return 0.00
total = sum(grades)
avg = total / len(grades)
weighted_avg = avg *0.8
return round(weighted_avg, 2)
# Part 3
def weighted_exams(mt1=None, mt2=None, fe=0):
if mt1 is None:
mt1= fe
if mt2 is None:
mt2= fe
wmt1f =0
wmt2f =0
wfer =0
for i in range(mt1+1):
wmt1f = mt1*0.15
for i in range(mt2+1):
wmt2f = mt2*0.15
for i in range(fe +1):
wfer = fe *0.30
return [wmt1f, wmt2f, wfer]
# Part 4
# put your code here make sure the test cases are correct

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!