How can I fix the error in the below code
enter code here`
import statistics
def avgScoreComput(studname, sDictKeys):
studName = studname
qContrib = ''
hContrib = ''
aContrib = ''
eContrib = ''
ScoreList = []
grade = ''
gpa = ''
status = ''
for rec in list(sDictKeys):
subject = list(rec.keys())[0]
subjScores = list(rec.values())[0]
for sub in list(subjScores.keys()):
if sub=='Quiz':
qContrib = (float(subjScores[sub])/190)*30
elif sub == 'HW':
hContrib = (float(subjScores[sub])/190)*15
elif sub == 'ATTND':
aContrib = (float(subjScores[sub])/96)*12
elif sub == 'Exam':
eContrib = (float(subjScores[sub])/100)*43
else:
print('assessment type unkown')
avgScore = qContrib +hContrib +aContrib + eContrib
ScoreList.append(avgScore)
print(avgScore)
Score = statistics.mean(ScoreList)
Score = round(Score, 2)
print(f'this is the mean score of the student: {Score}')
gpa = (Score/100)*5
if Score > 90:
grade = 'A'
elif Score > 75:
grade = 'B'
elif Score > 65:
grade = 'C'
elif Score > 55:
grade = 'D'
elif Score > 50:
grade = 'E'
else:
grade = 'F'
if grade in ['A','B','C','D']:
status = 'Pass'
elif grade == 'E':
status = 'Retake'
else:
status = 'Fail'
return ScoreList, Score, grade, gpa, status`
I want to hold each student performance in a container.
The below code is in next of my Jupyter note book after I empty the above code
res = avgScoreComput('Kwame Doga_GR-0486', studSubsDict['Kwame Doga_GR-0486'])
How can I get this working
the error shows as follows:
57.97552631578948
65.26631578947368
54.14736842105263
64.92842105263158
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [158], in <cell line: 1>()
----> 1 res = avgScoreComput('Kwame Doga_GR-0486', studSubsDict['Kwame Doga_GR-0486'])
Input In [157], in avgScoreComput(studname, sDictKeys)
14 subject = list(rec.keys())[0]
15 subjScores = list(rec.values())[0]
---> 17 for sub in list(subjScores.keys()):
18 #print(sub)
19 if sub=='Quiz':
20 qContrib = (float(subjScores[sub])/190)*30
AttributeError: 'list' object has no attribute 'keys''''