一小球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它
在第10次落地时,共经过多少米?第10次反弹多高?
high=[]
tour=[]
hei=100
for i in range(0,10):
if i == 0:
tour.append(hei)
else:
tour.append(2*hei)
hei /= 2
high.append(hei)
print('总高度:tour = {0}'.format(sum(tour)))
print('第10次的高度:height = {0}'.format(high[-1]))
h =100
list =[]
for i in range(10):
h=h/2
list.append(h)
print(sum(list)+100)
summ = 0.0
high=100.0
for i in range(0,10):
if i == 0:
summ += high
else:
summ += high *2
high /= 2
print('总高度为{}米'.format(round(summ,4)))
print('第10次的高度为{}米'.format(round(high,4)))
def ball(num):
totaldistance = 100
hei = []
for i in range(0, num):
if num == 1:
hei.append(100 / 2)
totaldistance += 100 / 2
else:
hei.append(100 / pow(2, i)/2)
totaldistance += 100 / (pow(2, i))
print("小球总共经过:", totaldistance)
print("第{}次反弹的高度:{}".format(num, hei[num - 1]))