python语⾔程序设计基础课后题3.3
python语⾔程序设计基础课后题3.3
3.3 天天向上续。采⽤程序练习题3.2的能⼒增长模型,如果初始能⼒值为1,固定每10天休息1天,365天后能⼒值是多少?如果每15天休息1天呢?
#课后题3.3.py
power=1.0
study='y'
unstudy='n'
temp=0
for i in range(365):
if i%11==10:
state='n'
else:
state='y'
if state==study and (temp in [0,1,2]):
power*=1
temp=(temp+1)%7
elif state==study and (temp in [3,4,5,6]):
power*=(1+0.01)
temp=(temp+1)%7
elif state==unstudy:
python基础程序设计
power*=1
temp=0
print("365天后的能⼒值是:{:.3f} ".format(power))