软件工程四则运算性能提升
源码地址:https://github.com/Wallrving/Wallhub
PSP表格
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
|
预计耗时(分钟) |
实际耗时(分钟) |
|
Planning |
计划 |
30 |
20 |
Estimate |
估计这个任务需要多少时间 |
30 |
20 |
Development |
开发 |
170 |
330 |
Analysis |
需求分析 |
30 |
60 |
Design Spec |
生成设计文档 |
20 |
30 |
Design Review |
设计复审(与同事审核设计文档) |
/ |
/ |
Coding Standerd |
代码规范(为目前的开发制定合适的规范) |
/ |
/ |
Design |
具体设计 |
120 |
240 |
Coding |
具体编码 |
60 |
60 |
Code Review |
代码复审 |
60 |
60 |
Text |
测试(自测,修改代码,提交修改) |
30 |
30 |
Reporting |
报告 |
60 |
60 |
Text Report |
测试报告 |
55 |
55 |
Size MeaSurement |
计算工作量 |
5 |
5 |
Postmortem & Process Improvement Plan |
事后总结,并提出过程改进计划 |
/ |
/ |
Sum |
合计 |
410 | 560 |
(1)功能提升
能自动生成一定数量的四则运算题目:
代码如下:
import random from fractions import Fraction def zhengshu(): fh = ['+', '-', '×', '÷'] a = random.randint(0, 3) n1 = random.randint(1, 100) n2 = random.randint(1, 100) result = 0 if a == 0: result = n1 + n2 elif a == 1: n1, n2 = max(n1, n2), min(n1, n2) result = n1 - n2 elif a == 2: result = n1 * n2 elif a == 3: n1, n2 = max(n1, n2), min(n1, n2) while n1 % n2 != 0: n1 = random.randint(1,100) n2 = random.randint(1,100) n1, n2 = max(n1, n2), min(n1, n2) result = int(n1/n2) print(n1, fh[a], n2, '=', end='') return result def fenshu(): fh = ['+', '-', '×', '÷'] a = random.randint(0, 3) t1 = random.randint(1, 100) t2 = random.randint(t1, 100) n1 = Fraction(t1, t2) t3 = random.randint(1, 100) t4 = random.randint(t1, 100) n2 = Fraction(t3, t4) result = 0 if a == 0: result = n1 + n2 elif a == 1: n1, n2 = max(n1, n2), min(n1, n2) result = n1 - n2 elif a == 2: result = n1 * n2 elif a == 3: n1, n2 = max(n1, n2), min(n1, n2) result = n1 / n2 print(n1, fh[a], n2, '=', end='') return result def newtest(): opr = ['+', '-', '×', '÷'] print('输入题库所需要的题目数量') n=int(input()) rjg=[] m=0 while m<=(n-1): fh = random.randint(0, 4) if fh==0: print(m+1,end='、') rjg.append(zhengshu()) print(' ') else: print(m+1,end='、') rjg.append(fenshu()) print(' ') m=m+1 m=0 print('答案:') while m<=(n-1): print(m+1,'、',rjg[m]) m=m+1 print('1、四则运算') print('2、制作题库') n=int(input()) if n==1: print('input "0000" to Quit') while True: fh = random.randint(0, 4) if fh == 0: rjg = zhengshu() jg = input() if jg == '0000': break; sr = Fraction(jg) if sr == rjg: print('right') else: print('error. the Tight answer is', rjg) else: rjg = fenshu() jg = input() if jg == '0000': break; sr = int(jg) if sr == rjg: print('right') else: print('error. the Tight answer is', rjg) if n==2: newtest()
测试结果

更多精彩