please use python to solve the problem. 3. Write a function, assignGrades(gradel
ID: 3605925 • Letter: P
Question
please use python to solve the problem.
3. Write a function, assignGrades(gradelist) which takes a list of numeric grades and assigns a letter value to each. The numeric grade and the letter valu list and that list appended to a master list of grades. 90 and above is an A. 80 and above is a B. 70 and above is a C. 60 and above is a D. Anything below a 60 is an F e are saved to a >>assignGrades (90,80,70,60,50]) E90, 'A'], [80, 'B'1, [70, 'C'], 060, 'D'], [50, 'F'11 >assignGradesCE92,82,72,62,52]) CC92, 'A'1, 82, 'B'], 072, 'C'], [62, 'D'], [52, 'F'1 >>assignGrades(L10]) CC10, 'F'1] >assignGradesCD) C1 ()Explanation / Answer
def assignGrades(list):
temp=[]
master=[]
for x in list:
if(x>=90):
temp=[x,'A']
master.append(temp)
elif(x>=80):
temp=[x,'B']
master.append(temp)
elif(x>=70):
temp=[x,'C']
master.append(temp)
elif(x>=60):
temp=[x,'D']
master.append(temp)
else:
temp=[x,'F']
master.append(temp)
return master
print(assignGrades([10,20,30]))
print(assignGrades([90,80,70,6,0,50,40,60]))
print(assignGrades([]))
print(assignGrades([100,101,50,60,75,85,95]))
#code is self explanatory, but for reference
#temp is a list with a score (x), and its grade alphabet
#master is the master list which is returned after adding all the elements
#then there are if elif else coditions, which first checks the higher side
#like first it will check if x>=90 if not then only it will check if x>=80, with this,x is automatically checked for
#x<90 and x>=80, if yes, then B is the grade assigned
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.