我是Python的新手,我正在上一个教我该语言的课程。现在,我们刚刚学习了条件语句,我的任务是编写基于三个加权类别(如代码所示)计算学生平均绩点的代码。但是,我只能根据一定的百分比打印出GPA。4.0等于94及以上,3.5代表89,3.0代表80,2.5代表75,2.0代表70,1.5代表65,1.0代表60,低于60的任何东西都是0。我的老师说我必须用这些数字。如果百分比不符合这些条件,我不知道如何计算平均绩点。有人能帮忙解决这个问题吗?在#Scores (made up point totals)
avgHwScore = float(input('What was your average homework score? (Out of 5)\n>>> '))
midTerm = float(input('What was your score on the mid-term? (Out of 30)\n>>> '))
finalExam = float(input('What was your score on the final exam? (Out of 50)\n>>> '))
#Converting to decimal
hwDec = avgHwScore/5
midDec = midTerm/30
finalDec = finalExam/50
#Weighted grades
hwWeighted = hwDec*.6
midWeighted = midDec*.2
finalWeighted = finalDec*.2
print('\nThe homework is weighted 60% and the mid-term and final exam are both weighted 20% each\n')
print('You earned ' + str(hwWeighted*100) + '% out of 60% in the homework category')
print('You earned ' + str(midWeighted*100) + '% out of 20% on mid-term category')
print('You earned ' + str(finalWeighted*100) + '% out of 20% on the final exam category\n')
#Final grade
finalGrade = (hwWeighted + midWeighted + finalWeighted)*100
if finalGrade >= 94:
print('Your final grade is ' + str(finalGrade) + '%. You have a 4.0 in the class')
elif finalGrade == 89:
print('Your final grade is ' + str(finalGrade) + '%. You have a 3.5 in the class')
elif finalGrade == 80:
print('Your final grade is ' + str(finalGrade) + '%. You have a 3.0 in the class')
elif finalGrade == 75:
print('Your final grade is ' + str(finalGrade) + '%. You have a 2.5 in the class')
elif finalGrade == 70:
print('Your final grade is ' + str(finalGrade) + '%. You have a 2.0 in the class')
elif finalGrade == 65:
print('Your final grade is ' + str(finalGrade) + '%. You have a 1.5 in the class')
elif finalGrade == 60:
print('Your final grade is ' + str(finalGrade) + '%. You have a 1.0 in the class')
elif finalGrade < 60:
print('Your final grade is ' + str(finalGrade) + '%. You have a 0.0 in the class')