AcWing 718. 实验 - Python3
原题链接
困难
作者:
KYCygni
,
2021-03-13 09:58:29
,
所有人可见
,
阅读 229
Python3 代码
n = int(input())
c = r = f = 0
for i in range (n):
e = input().split()
if e[1] == "C":
c += int(e[0])
elif e[1] == "R":
r += int(e[0])
elif e[1] == "F":
f += int(e[0])
total = c + r + f
print ("Total:", total, "animals")
print ("Total coneys:", c)
print ("Total rats:", r)
print ("Total frogs:", f)
print ("Percentage of coneys:",f'{c * 100/total:.2f}', "%")
print ("Percentage of rats:", f'{r * 100/total:.2f}', "%")
print ("Percentage of frogs:", f'{f * 100/total:.2f}', "%")