弹跳球距离

时间:2016-05-26 18:31:45

标签: python

我正在尝试制作一个程序,允许我输入要丢弃的球的高度并输入反弹次数并给我总距离。我的方程式有问题,请看一些在视线内。

h = int(input("Enter hieght"))
b = int(input("Enter Number of Bounces"))


for eachPass in range (b):
    d = h * 0.6

    if b >= 1:
        bounce1 = h + d
        if b >= 2:
            bounce2 = (d * 0.6) + bounce1 + d

        print (bounce2)

1 个答案:

答案 0 :(得分:1)

虽然我无法确定,但我相信你想要这样的东西

h = int(input("Enter height"))
b = int(input("Enter Number of Bounces"))
bounce1 = 0
bounce2 = 0
d = h * 0.6
for eachPass in range(b):
    if eachPass == 1:
        bounce1 = h + d
    if eachPass == 2:
        bounce2 = bounce1 + h + d

print str(bounce2)