L1-017 到底有多二 python

python实现

s=str(input())

factor1=1.0
if s[0]=="-":
    factor1=1.5
    s=s[1:]

l=len(s)
count=0
for i in s:
    if i=="2":
        count+=1

factor2=1.0
if int(s)%2==0:
    factor2=2.0

print("{:.2f}%".format((count/l)*factor1*factor2*100))

 

posted @ 2024-07-03 16:21  豆豆是只乖狗狗  阅读(3)  评论(0编辑  收藏  举报