Python语言程序设计课程(MOOC嵩天)第三章程序整理(0210)
发布时间
阅读量:
阅读量
第三章
练习1 天天向上的力量
def DUP (upr): #自定义函数,包括函数名和变量
base=1
for i in range(365):
if i%7 in [0,6]: #如果余数为0/6,证明为周末
base=base*(1-0.01)
else:
base=base*(1+upr)
return base
upr=0.01 #命名重复,尽量避免
while DUP(upr)<37.78: #如果进步不够
upr=upr+0.001 #提高工作日努力程度0.001
print("工作日的努力参数是: {:.3f}".format(upr)) #格式化输出
文本进度条实现与优化
import time
scale = 50 #刻度
print("执行开始".center(scale//2,'-'))
全部评论 (0)
还没有任何评论哟~
