本文共 370 字,大约阅读时间需要 1 分钟。
# (选做)一个小球从100m高度落下,每次弹回原高度一半.# 计算:# -- 总共弹起多少次?(最小弹起高度0.01m)# -- 全过程总共移动多少米?# 提示:# 数据/算法 print("总共弹起%s次,全过程总共移动%s米"%(str(count),))count = 0sum = 100distance = height = 100while height / 2 > 0.01: height /= 2 count += 1 distance += height * 2 print(height) print(count) print("总共弹起%s次,全过程总共移动%f米" % (str(count), distance))
转载地址:http://cynqi.baihongyu.com/