题解 | #牛牛的绩点#

牛牛的绩点

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))


最愚笨的方法

全部评论

相关推荐

09-01 11:31
门头沟学院 Java
buul:七牛云的吧,感觉想法是好的,但是大家没那么多时间弄他这个啊。。。不知道的还以为他是顶尖大厂呢还搞比赛抢hc,只能说应试者的痛苦考察方是无法理解的,他们只会想一出是一出
点赞 评论 收藏
分享
迷茫的大四🐶:哇靠,哥们,啥认证啊,副总裁实习,这么有实力嘛
一起聊美团
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务