python编写篮球_Python编程2——Python实现计算篮球比赛是否领先安全的程序
前言
這個程序的算法部分是Bill James 博士的’Safe lead calculator’
網址:http://www.slate.com/articles/sports/sports_nut/2008/03/the_lead_is_safe.html
這里有一個基于swf的計算器的實現http://img.slate.com/media/53/LeadCalc2.swf
程序
這里我全部略過算法的說明部分,直接上程序了。
#Bill James 'Safe lead calculator'
#from http://www.slate.com/id/2185975/
#take the number of points one team ahead
pointsStr=raw_input("Enter the number of the lead in the play: \n")
pointsInt=int(pointsStr)
#subtract threee
points=pointsInt-3
#add a half-point or not
#depenf the ball is has or not
has_ball=raw_input("Does the lead team has the ball or not(Yes or No): \n")
if has_ball == 'Yes':
points=points+0.5
else:
points=points-0.5
if points < 0:
points=0
#square the points to get the conclusion
points=points **2
#to judge the condition whether we should judge there should the
#time that left
seconds=int(raw_input("Enter the number of seconds remaining: \n"))
if points > seconds:
print "Lead is safe!"
else:
print "Lead is not safe!"
總結
以上是生活随笔為你收集整理的python编写篮球_Python编程2——Python实现计算篮球比赛是否领先安全的程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用vsftp作为集群的yum仓库
- 下一篇: 全志科技公司A83T Qt 支持双屏显示