[python practice questions] program 20

#Question : A ball that falls freely from a height of 100 meters, bounces back to half of its original height after each landing, and then falls again, how many meters does it travel through the 10th time it hits the ground? How high is the 10th rally? 

# This answer can be customized for any height and number of bounces, concludes
def dist(x,y,s): while y >0: s +=(1.5*x) x = 0.5*x y = y - 1 return dist(x,y,s) print(x,s) dist(100,10,0)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325067149&siteId=291194637