前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python 程序小测试

python 程序小测试

作者头像
py3study
发布2020-01-16 15:46:29
1.1K0
发布2020-01-16 15:46:29
举报
文章被收录于专栏:python3python3python3

python 程序小测试

对之前写的程序做简单的小测试 ...

 1 # -*- encoding:utf-8 -*-
 2 '''
 3 对所写程序做简单的测试
 4 @author: bpf
 5 '''
 6 def GameOver(N, scoreA, scoreB):
 7     '''
 8     function: 定义一局排球比赛的结束条件
 9     N: 代表当前局次(第五局为决胜局)
10         前四局,每个队只有在赢得至少25分,且同时超过对方2分时才胜一局
11         第五局,每个队只有在赢得至少15分,且同时超过对方2分时才胜一局
12     return: 若比赛结束的条件成立返回真,否则为假 15
13     '''
14     if N <= 4:
15         return (scoreA>=25 and abs(scoreA-scoreB)>=2) or (scoreB>=25 and abs(scoreA-scoreB)>=2)
16     else:
17         return (scoreA>=15 and abs(scoreA-scoreB)>=2) or (scoreB>=15 and abs(scoreA-scoreB)>=2)
18 
19 def Test():
20     try:
21         N = [1, 2, 3, 4, 5, 5, 5]
22         scoreA = [13, 24, 26, 24, 14, 17, 15]
23         scoreB = [25, 25, 25, 0, 16, 16, 0]
24         result = ["True", "False", "False", "False", "True", "False", "True"]
25         for i in range(0, 7):
26             if str(GameOver(N[i], scoreA[i], scoreB[i])) == result[i]:
27                 print("Test {}: Right Result!".format(i+1))
28             else:
29                 print("Test {}: Error Result!".format(i+1))
30     except Exception as e:
31         print("Error:", e) 2 
33 Test()

参考文献: 

① https://www.liaoxuefeng.com/wiki/897692888725344/923056208268256

② https://blog.csdn.net/u012084802/article/details/79481254

③ https://www.cnblogs.com/springionic/p/10711796.html

④ https://docs.python.org/2/library/profile.html

⑤ https://blog.csdn.net/asukasmallriver/article/details/74356771

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-06-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档