"""
这是一款打字机软件,
它能帮助你打字更快、更准确。
注: 此软件需要 Python 3.8 以上的解释器才能运行。
"""
import random
from random import choice
import time
def mode_1():
def gen_sentence():
name = [
"我",
"太空人",
"太空狼",
"爷爷",
"奶奶",
"爷爷奶奶",
"喜之郎果冻",
"喜之郎",
"洗只狼",
"爸爸",
"妈妈",
"世界冠军",
"世界吃人冠军",
"世界吃狼冠军",
"航天飞机",
"太空",
"世界足球先生",
"世界",
"足球",
"世界杯",
"发明家",
"药",
"狼",
"狼人",
]
action = ["吃", "喝", "当", "画", "鼓励", "旅游", "踩"]
adj = ["高兴", "伤心", "当人", "生气", "美丽"]
return f"{choice(name)}{choice(['','长大了'])}要{choice(action)}{choice(name)},{choice(name)}可{choice(adj)}了,给{choice(name)}爱{choice(action)}的{choice(name)}。"
right = 0
wrong = 0
times = []
print("喜之郎果冻笑话")
print()
while True:
time.sleep(2)
print("请输入以下句子 ( 输入 0 退出 )")
sentence = gen_sentence()
print(sentence)
start = round(time.time(), 2)
answer = input()
end = round(time.time(), 2)
t = round(end - start, 2)
if answer == "0":
break
elif answer == sentence:
print(f"你对了,用时 {t} 秒")
print()
times.append(t)
right += 1
else:
print(f"你错了,用时 {t} 秒")
print()
times.append(t)
wrong += 1
if len(times) != 0:
print(f"你对了 {right} 个,错了 {wrong} 个,平均速度是 {round(sum(times) / len(times), 2)} 秒")
print()
else:
print("退出")
print()
def mode_2():
right = 0
wrong = 0
times = []
while True:
time.sleep(2)
print("请输入以下验证码 ( 输入 0 退出 )")
code = str(random.randint(100000, 999999))
print(code)
start = round(time.time(), 2)
answer = input()
end = round(time.time(), 2)
t = round(end - start, 2)
if answer == "0":
break
elif answer == code:
print(f"你对了,用时 {t} 秒")
print()
times.append(t)
right += 1
else:
print(f"你错了,用时 {t} 秒")
print()
times.append(t)
wrong += 1
if len(times) != 0:
print(f"你对了 {right} 个,错了 {wrong} 个,平均速度是 {round(sum(times) / len(times), 2)} 秒")
print()
else:
print("退出")
print()
print("欢迎来到 TypeWriter v0.0.1")
print()
print("请选择模式 ( 输入 0 退出 )")
print("1.抄句子")
print("2.抄验证码")
while (mode := input("选择: ")) != "0":
print()
if mode == "1":
mode_1()
print("请选择模式 ( 输入 0 退出 )")
print("1.抄句子")
print("2.抄验证码")
elif mode == "2":
mode_2()
print("请选择模式 ( 输入 0 退出 )")
print("1.抄句子")
print("2.抄验证码")
else:
print("你的选择有误,请重新", end="")
# 之后他会 input("选择: ") ,也就是输出 "你的选择有误,请重新选择: "