python爬蟲 用python編程,一球從100米高度自由落下,每次落地后反跳回原高度的一半再落下?
用python編程,一球從100米高度自由落下,每次落地后反跳回原高度的一半再落下?high=100n=10high|All=0|第n次著陸的長(zhǎng)度high|Each=0|每次著陸的高度,def bal
用python編程,一球從100米高度自由落下,每次落地后反跳回原高度的一半再落下?
high=100n=10high|All=0|第n次著陸的長(zhǎng)度high|Each=0|每次著陸的高度,def ball|lands(n):當(dāng)球第一次著陸時(shí),全局high|All,high|Each,high|,如果n==0:high_35;each=high high_35;all=high_35;each#print(“1”,high_35;each,high_35;all)return high_35;each#從球的第n次落地開始向前推高35; each=high*(1/2)**n print(U)“球在%d反彈時(shí)的高度為:%。2F “%(n,high) each))high all=high each*2 print(”2“,high each,high each)ball lands(n-1)ball lands(n)print(U)”球落下%d次,共%d次。2F米?!?(n,全部高))