重庆邮电大学Python课后作业 4. 绩点计算 ---- (第三次作业)


原题题目

在这里插入图片描述

在这里插入图片描述


代码实现

credits = score = 0
gpa = [4.0,3.7,3.3,3.0,2.7,2.3,2.0,1.5,1.3,1.0,0];level = ['A','A-','B+','B','B-','C+','C','C-','D','D-','F']
while True:
    str = input()
    if(str == '-1'):break
    else:
        temp = float(input())
        score += temp*gpa[level.index(str)]
        credits += temp
print("%.2f" %(score/credits))


优雅的代码 来自茄皇的震惊

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_37500516/article/details/115004384