精品熟女碰碰人人a久久,多姿,欧美欧美a v日韩中文字幕,日本福利片秋霞国产午夜,欧美成人禁片在线观看

Python 練習(xí)實例20

python 練習(xí)實例20

python 編程100例python 編程100例

題目:一球從100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地時,共經(jīng)過多少米?第10次反彈多高?

程序分析:無

程序源代碼:

python 實例:

#!/usr/bin/python
# -*- coding: utf-8 -*-
 
tour = []
height = []
 
hei = 100.0 # 起始高度
tim = 10 # 次數(shù)
 
for i in range(1, tim + 1):
    # 從第二次開始,落地時的距離應(yīng)該是反彈高度乘以2(彈到最高點再落下)
    if i == 1:
        tour.append(hei)
    else:
        tour.append(2*hei) 
    hei /= 2
    height.append(hei)
 
print('總高度:tour = {0}'.format(sum(tour)))
print('第10次反彈高度:height = {0}'.format(height[-1]))

以上實例輸出結(jié)果為:

總高度:tour = 299.609375
第10次反彈高度:height = 0.09765625

python 編程100例python 編程100例

下一節(jié):python 練習(xí)實例21

python 編程100例

相關(guān)文章