dic={'A':4.0,'A-':3.7,'A+':3.3,'B':3.0,'B-':2.7,'C+':2.3,'C':2.0,'C-':1.5,'D':1.3,'D-':1.0}
temp=0
total=0
while True:
ch=input()
num_=dic.get(ch)
num=eval(input())
if ch=='-1':
break
else:
temp+=num
total+=num*num_
result=total/temp
print("{:.2f}".format(result))
报错:unexpected EOF while parsing
输入-1时跳出循环
帮我康康是哪里出了问题 ball ball 了
昨天有人问了
sore={'A':'4.0','A-':'3.7','B+':'3.3','B':'3.0','B-':'2.7','C+':'2.3','C':'2.0','C-':'1.5','D':'1.3','D-':'1.0'}
sum=0
q=0
for i in range(100):
s=input()
if s=='-1':
break
c=float(input())
b=sore.get(s)
b=float(b)
p=b*c
q=q+c
sum=sum+p
pre=sum/q
print("{:.2f}".format(pre))
要想研究你的问题。 用插入代码块功能贴代码,这样好看