grade_point_dict = {'A':4.0,'B':3.0,'C':2.0,'D':1.0,'F':0}
grade_point = []
score = []
while True:
x = input()
if x == 'False':
break
elif x in grade_point_dict.keys():
grade_point.append(float(grade_point_dict[x]))
else:
score.append(float(x))
print(grade_point,score)
muti = lambda x,y:x*y #lambda相乘
muti_score = list(map(muti,grade_point,score)) #实现list相乘
print("The muti_score is ",muti_score,type(muti_score))
point_score = sum(muti_score)
sum_score = sum(score)
average = point_score/sum_score
#sum_score = 0
#for x in muti_score:
# sum_score += x
print('%.2f'% average)
python计算两个列表重合的函数 python中两个列表怎么相乘
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章