File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+ import random
3+ import time
4+
5+ print ("贴贴我的百花酱!数字打字练习\n " )
6+ print ("程序会随机生成若干组0至99999999的整数,每输入一组按回车键继续;要结束练习,请输入-1并回车。" )
7+ print ("练习结束后会显示所用时间、完成数目和输入速度,并列出输入错误的数字。\n " )
8+ input ("按回车键开始:" )
9+
10+ wrongList = []
11+ sum = 0
12+ start_time = time .time ()
13+ while True :
14+ target = random .randint (0 , 99999999 )
15+ print (str (target )+ ": " , end = '' )
16+ answer = int (input ())
17+ if answer == - 1 :
18+ break
19+ sum += 1
20+ if target != answer :
21+ wrongNum = (target , answer )
22+ wrongList .append (wrongNum )
23+ end_time = time .time ()
24+
25+ print ("\n 错误列表:" )
26+ print ("正确答案\t 你的输入" )
27+ for wrongNum in wrongList :
28+ print (str (wrongNum [0 ]) + "\t " + str (wrongNum [1 ]))
29+ used_time = end_time - start_time
30+ print ("\n 练习" + str (sum ) + "个,错误" + str (len (wrongList )) + "个,用时" + str (int (used_time )) + "秒,有效平均速度为每分钟" + str (format (float ((sum - len (wrongList ))/ (used_time / 60 )), '.1f' )) + "个。\n " )
31+
32+ print ("加油呀,爱你喔~\n " )
33+ input ("按回车键退出……" )
You can’t perform that action at this time.
0 commit comments