问:一颗球从100米处落下,每次弹起高度减半,问弹跳n次后的高度,路程
def Ayue(): i =1 num = 100.0 x = float(input("请输入你想要知道的弹跳次数:")) sum = 100 * (1/2) ** (x) print(f"最后的高度为:{sum}") while (i<=x): num += 100*(1/2)**(i) i = i+1 print(f"经过{x}弹跳后的路程为:{num}") print(Ayue())
标签:python,sum,练习,高度,100,弹跳 From: https://www.cnblogs.com/ayue6/p/17768243.html