天天向上的力量
天天向上的力量
1. 每一天都学习,每一天都会进步,假设你每天进步0.001,一年之后呢?
base = 1
for i in range (365):
base*=(1+0.001)
print(base) # 1.440251313429521
等同于
print(pow(1.001,365)) # 1.4402513134295205
2. 每天退步0.0001? ===》 (1-0.0001)
print(pow(0.9999,365)) # 0.9641563341920977
3. 周一到周五进0.01,然后双休日退步0.01,这个怎么计算?
# 5 2 5 2 5 2
# 7 7 7 7
# 1 8 15 22 周一 # 除7余1
# 2 9 16 23 周二 # 除7余2
# 3 10 17 24 周三 # 除7余3
# ... ...
# 周六 # 除7余6
# 周日 # 除7余0
base = 1
factory = 0.01
for i in range(365): # i=1周一
if i % 7 == 6:
base *= (1-0.01)
elif i % 7 == 0:
base *= (1-0.01)
else:
base *= (1+factory)
print(base) # 4.626500529730141
4. 周一到周五努力到什么程度才能 == 每天进步0.01?
# 每天进步0.01:base = pow(1.01,365)
factory = 0.01
for i in range(1000000):
base = 1
for i in range(365):
if i % 7 == 6:
base *= (1 - 0.01)
elif i % 7 == 0:
base *= (1 - 0.01)
else:
base *= (1 + factory)
if pow(1.01,365) < base:
print(factory)
break
factory += 0.001 # 0.019000000000000006