admin管理员组

文章数量:1567560

2023年12月12日发(作者:)

python双手打字_Python打字练习小游戏源代码

Python打字练习小游戏源代码

Python代码狂人 Python代码大全

Python打字练习小游戏源程序,随机产生一串字符,可对打字练习的正确率和时间进行统计,运行截图如下:

from tkinter import *

import random

import string

from datetime import datetime

root = Tk()

("Python打字练习 By:Python代码狂人")

Label(root, text='系统题目:').grid(row=0)

Label(root, text='用户作答:').grid(row=1)

Label(root, text='考试结果:').grid(row=2)

v1 = StringVar()

v2 = StringVar()

v3 = StringVar()

("点击'开始测试'按钮开始出题")

e1 = Entry(root, text=v1, state='disabled', width=40, font=('宋体', 14))

e2 = Entry(root, textvariable=v2, width=40, font=('宋体', 14))

e3 = Label(root, textvariable=v3, width=40, font=('宋体', 10), foreground='red')

(row=0, column=1, padx=10, pady=20)

(row=1, column=1, padx=10, pady=20)

(row=2, column=1, padx=10, pady=20)

text = Text(root, width=80, height=7)

(row=4, column=0, columnspan=2, pady=5)

class TypingTest:

def __init__(self):

_list = []

Num = 20

Str = ''.join(((' ')[0], Num))

ation_paper = ''

def time_calc(self):

_(())yield

def create_exam(self):

(0.0, END)

# (0, END)

(Str)

_calc().__next__()

(END, "开始:%s n" % str(_list[-1]))

user_(state='active')

def score(self):

wrong_index = []

_calc().__next__()

(END, "结束:%sn" % str(_list[-1]))

use_time = (_list[-1] - _list[-2]).seconds

ation_paper = ()

if len(ation_paper) > Num:

("输入数据有误,作答数大于考题数")

else:

right_num = 0

for z in range(len(ation_paper)):

if ation_paper[z] == Str[z]:

right_num += 1

else:

wrong_(z)

if right_num == Num:

("完全正确,正确率%.2f%%用时:%s秒" % ((right_num * 1.0) / Num * 100, use_time))

else:

("正确率%.2f%%用时:%s 秒" % ((right_num * 1.0) / Num * 100, use_time))

# (0, END)

(END, "题目:%sn" % Str)

tag_info = list(map(lambda x: '4.' + str(x + 3), wrong_index))

(END, "作答:%sn" % ation_paper)

for i in range(len(tag_info)):

_add("tag1", tag_info[i])

_config("tag1", background='red')user_(state='disabled')TypingTest = TypingTest()Button(root, text="开始测试", width=10, command=_exam).grid(row=3, column=0, sticky=W, padx=30,pady=5)user_only1 = Button(root, text="交卷", width=10, command=, state='disable')user_(row=3, column=1, sticky=E, padx=30, pady=5)mainloop()

本文标签: 打字练习作答开始小游戏