题解 | #牛牛的绩点#
牛牛的绩点
https://www.nowcoder.com/practice/de8bc3e736164786b07a4dd64ed172f7
grade_dict = {'A':4.0, 'B':3.0, 'C':2.0, 'D':1.0, 'F':0}
list_all = []
grade_list = []
score_list = []
while True:
a = input()
if a == 'False':
break
list_all.append(a)
grade_list = list_all[::2]
list_all.pop(0)
score_list = [float(x) for x in list_all[::2]]
score = 0.0
for i in range(len(grade_list)):
score = score + grade_dict[grade_list[i]]*score_list[i]
print('%.2f'%(score/sum(score_list)))
list_all = []
grade_list = []
score_list = []
while True:
a = input()
if a == 'False':
break
list_all.append(a)
grade_list = list_all[::2]
list_all.pop(0)
score_list = [float(x) for x in list_all[::2]]
score = 0.0
for i in range(len(grade_list)):
score = score + grade_dict[grade_list[i]]*score_list[i]
print('%.2f'%(score/sum(score_list)))