用户:
小峰BOY查看:2 回复:3 评论:2 创建时间:2022-07-21T22:11:22
我发帖的时间是我五升六年级的时候,我三年级开始创作这个内容,修改了无数次,放到我的海龟编辑器里了,叫“PyWord2.0”,我希望可以给需要的人提供一些帮助,谢谢。话不多说,看代码!
import random as r
import time
words = ["print", "input", "str", "int", "import", "random", "randint", "def", "and", "or", "not", "while", "for", "if", "else", "as", "append", "pop", "elif", "list", "in", "turtle", "choice", "time", "break", "return", "remove", "continue", "true", "false", "try", "except", "pass"]
喵 = list()
def pas(a, b):
print(a)
time.sleep(b)
pas("Python计时关键字打字练习,共十个关键字!", 2)
pas("准备!", 2)
pas("3", 1)
pas("2", 1)
pas("1", 1)
t = 0
cnt = 0
maxt = 20
t1 = time.time()
for i in range(1, 11):
c = r.choice(words)
words.remove(c)
d = input(str(i) + ".请输入" + c + ":")
if d == c:
t += 1
else:
cnt += 1;
喵.append(str(cnt) + ". 第" + str(i) + "个单词 " + c)
t2 = (time.time() - t1) // 0.1 / 10
pas("---------------------------------", 1)
pas(" 快来看看你的成绩吧!", 0.3)
print(" 满分:100分 得分:%s分" % (t * 10))
time.sleep(0.3)
print(" 共10个关键字 对%s个 错%s个" % (t, 10 - t))
time.sleep(0.3)
if (t < 10 and t > 0):
pas(" 错 词 表 :", 0.3)
for j in 喵:
print(" %s" % j)
time.sleep(0.1)
print(" 用时%ss 历史记录:%ss" % (t2, maxt))
time.sleep(0.3)
if (t == 10):
if (t2 < maxt):
print("你打破了历史记录,比旧记录快%.1fs!" % (maxt - t2))
else:
print(" 成绩不错,离历史纪录还差%.1fs!" % (t2 - maxt))
else:
print(" 只有满分才可以和历史记录对比哦!")
(注意第15行的maxt变量是可以改的!指的是历史记录!)
林俊贤1print()input()int()str()float()random()randint()append()pop()list()turtle()choice()time()remove()不是关键字哟
点赞1
评论