题目:
假设一个球从任意高度自由落下,每次落地后反跳回原高度的一半; 再落下, 求它在第5次落地时,共经历多少米?第5次反弹多高? 最后的误差判断是小数点6位
代码:
height = int(input()) #球的起始高度
total = height #球落地时经过的你米数总和
for n in range(0,4):
total = total + height / (2 **n)
print(total)
#print(height)
height1 = height / (2 ** 5) #第5次落地后弹起的高度
print(height1)