# 代码来自北京理工大学慕课课程-Python程序设计
# 每天进步0.01和每天退步0.01一年下来会有什么变化?
dayup_1 = 1.0
dayup_2 = 1.0
dayfactor = 0.01
for i in range(365):
dayup_1 *= (dayfactor+1)
for i in range(365):
dayup_2 *= (1-dayfactor)
print("一年下来进步变为:{},退步变为:{}".format(dayup_1,dayup_2))
# 工作日进步0.01非工作日退步0.01一年下来会有什么变化?
dayup = 1.0
dayfactor = 0.01
for i in range(365):
if i % 7 in [6,0]:
dayup = dayup*(1-dayfactor)
else:
dayup = dayup*(1+dayfactor)
print("工作日进步0.01非工作日退步0.01一年下来会变为:{}".format(dayup))
天天向上-Python
于 2023-10-08 10:55:12 首次发布