题解 | #牛牛的绩点#
牛牛的绩点
https://www.nowcoder.com/practice/de8bc3e736164786b07a4dd64ed172f7
from dataclasses import make_dataclass
a=[]
b=[]
i=0
under=0
score=[]
total=0
while True:
temp=input()
if temp=='False':
break
else:
if i%2==0:
a.append(temp)
else:
b.append(int(temp))
i+=1
m=0
for i in a:
if i=='A':
score.append(4*b[m])
under+=b[m]
m+=1
elif i=='B':
score.append(3*b[m])
under+=b[m]
m+=1
elif i=='C':
score.append(2*b[m])
under+=b[m]
m+=1
elif i=='D':
score.append(1*b[m])
under+=b[m]
m+=1
else:
score.append(0*b[m])
under+=b[m]
m+=1
#print(a,b,sep='\n')
##print(score)
for i in score:
total+=i
#print(total)
#print(under)
print(f'{(total/under):.2f}')
#print('%.2f'%(total/under))
最愚笨的方法
查看10道真题和解析
