题解 | #牛牛的绩点#
牛牛的绩点
https://www.nowcoder.com/practice/de8bc3e736164786b07a4dd64ed172f7
pf = { 'A':4.0, 'B':3.0, 'C':2.0, 'D':1.0, 'F':0, } dic = {} while True: t = input() if t != 'False': if t in dic.keys(): dic[t]=dic[t] + float(input()) else: dic[t]= float(input()) else: break # print(list(dic.values())) sum_scores=sum(list(dic.values())) sum_scores_with_quan = 0.0 for i in list(dic.keys()): sum_scores_with_quan = sum_scores_with_quan + dic[i] * pf[i] print("%.2f" % (sum_scores_with_quan / sum_scores))