条件语句练习-比分预测

 1 #预测比分
 2 score=int(input('请输入比分:'))-3
 3 ctrl=int(input('是否控球,1=控,0=非控:'))
 4 
 5 
 6 if ctrl==1:
 7     score=score+0.5
 8 elif ctrl==0:
 9     score=score-0.5
10     
11 rest_time=int(input('请输入比赛剩余秒数时间:'))
12 
13 if score<0:
14     score=0
15 else:
16     score=score**2
17 if not (ctrl==1 or ctrl==0):
18     print('ERROR')
19 else:
20     if score>rest_time:
21         print('安全')
22     else:
23         print('不安全')
24     

自认为第一次写的不错的代码,逻辑还是比较严谨的。就是不能在第二次输入时直接报ERROR的错,还要请教高手!

posted @ 2016-06-21 00:40  dmdoge  阅读(171)  评论(0编辑  收藏  举报