中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

Python 練習實例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): # 從第二次開始,落地時的距離應該是反彈高度乘以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例

其他擴展