#DayDayUpQ4.py
 dayup = 1.0
 dayfactor = 0.01
 def dayUP(df):
     dayup = 1
     for i in range(365):
         if 1 % 7 in [6,0]:
                dayup = dayup*(1 - 0.01)
         else:
             dayup = dayup*(1 + df)
     return dayup
 dayfactor = 0.01
 while dayUP(dayfactor) < 37.78:
           dayfactor +=0.001
 print("工作日的努力参数是:{:.3f}".format(dayfactor))


 

翻译一下:

一天为1,一天上升或者下降的都为0.01,def定义函数,一周的周六周日不努力反而退步的下降0.01 ,else否则为上升0.01.然后回到dayup,再到后面给dayfactor下定义给予值。

{:.2f}的意思是小数点后两位,format数据格式化