基于Python编写一个刷题练习系统
作者:Want595 发布时间:2022-10-01 13:28:34
标签:Python,刷题,练习,系统
用python给自己做个练习系统刷题吧!
实现效果
实现代码
选择题
def xuanze():
global flag2
if flag2==1:
def insert():
num=var1.get()
question=var2.get()
choice=var3.get()
answer=var4.get()
with open('d:\\练习系统\\练习三3.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\练习系统\\练习三3.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\练习系统\\练习三3.3.pickle','rb') as file:
lst3=pickle.load(file)
with open('d:\\练习系统\\练习三3.4.pickle','rb') as file:
lst4=pickle.load(file)
if num not in lst1:
lst1.append(num)
lst2.append(question)
lst3.append(choice)
lst4.append(answer)
var5.set('录入成功')
else:
var5.set('录入失败')
with open('d:\\练习系统\\练习三3.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\练习系统\\练习三3.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\练习系统\\练习三3.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
with open('d:\\练习系统\\练习三3.4.pickle','wb') as file:
pickle.dump(lst4,file)
file.close()
def delete():
num=var1.get()
question=var2.get()
choice=var3.get()
answer=var4.get()
with open('d:\\练习系统\\练习三3.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\练习系统\\练习三3.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\练习系统\\练习三3.3.pickle','rb') as file:
lst3=pickle.load(file)
with open('d:\\练习系统\\练习三3.4.pickle','rb') as file:
lst4=pickle.load(file)
if num in lst1:
t=lst1.index(num)
lst1.pop(t)
lst2.pop(t)
lst3.pop(t)
lst4.pop(t)
var5.set('删除成功')
else:
var5.set('删除失败')
with open('d:\\练习系统\\练习三3.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\练习系统\\练习三3.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\练习系统\\练习三3.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
with open('d:\\练习系统\\练习三3.4.pickle','wb') as file:
pickle.dump(lst4,file)
file.close()
填空题
def tiankong():
global flag2
if flag2==1:
def insert():
num=var1.get()
question=var2.get()
answer=var3.get()
with open('d:\\练习系统\\练习一1.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\练习系统\\练习一1.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\练习系统\\练习一1.3.pickle','rb') as file:
lst3=pickle.load(file)
if num not in lst1:
lst1.append(num)
lst2.append(question)
lst3.append(answer)
var4.set('录入成功')
else:
var4.set('录入失败')
with open('d:\\练习系统\\练习一1.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\练习系统\\练习一1.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\练习系统\\练习一1.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
def delete():
num=var1.get()
question=var2.get()
answer=var3.get()
with open('d:\\练习系统\\练习一1.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\练习系统\\练习一1.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\练习系统\\练习一1.3.pickle','rb') as file:
lst3=pickle.load(file)
if num in lst1:
t=lst1.index(num)
lst1.pop(t)
lst2.pop(t)
lst3.pop(t)
var4.set('删除成功')
else:
var4.set('删除失败')
with open('d:\\练习系统\\练习一1.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\练习系统\\练习一1.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\练习系统\\练习一1.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
判断题
def panduan():
global flag2
if flag2==1:
def insert():
num=var1.get()
question=var2.get()
answer=var3.get()
with open('d:\\练习系统\\练习二2.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\练习系统\\练习二2.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\练习系统\\练习二2.3.pickle','rb') as file:
lst3=pickle.load(file)
if num not in lst1:
lst1.append(num)
lst2.append(question)
lst3.append(answer)
var4.set('录入成功')
else:
var4.set('录入失败')
with open('d:\\练习系统\\练习二2.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\练习系统\\练习二2.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\练习系统\\练习二2.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
def delete():
num=var1.get()
question=var2.get()
answer=var3.get()
with open('d:\\练习系统\\练习二2.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\练习系统\\练习二2.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\练习系统\\练习二2.3.pickle','rb') as file:
lst3=pickle.load(file)
if num in lst1:
t=lst1.index(num)
lst1.pop(t)
lst2.pop(t)
lst3.pop(t)
var4.set('删除成功')
else:
var4.set('删除失败')
with open('d:\\练习系统\\练习二2.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\练习系统\\练习二2.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\练习系统\\练习二2.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
来源:https://blog.csdn.net/m0_68111267/article/details/129108804
0
投稿
猜你喜欢
- 设计方法曾经是个很尴尬的话题,因为经常看上去很美。专业人士们动手动脚折腾一大圈,出来的结果令人大跌眼镜。也有些设计师总喜欢把方法、概念吹的特
- my.ini文件[mysqld]max_allowed_packet = 10M
- 前言undefined 和 null 的区别是个老生常谈的话题了,之前我对二者的区别只是简单理解,例如二者转成 Boolean 类型都是 f
- 目录什么是 JSON在哪里使用JSON基本的 JSON 语法如何在 Python 中处理 JSON 数据包含 JSON 模块使用 json.
- 一、简介是一个 python 内置包,不需要额外安装即可使用urllib 是 Python 标准库中用于网络请求的库,内置四个模块,分别是u
- asp取得字段属性代码:set AdoX = server.createobject("adox.c
- 1、查看数据库中有哪些用户? select username from all_users;2、查看数据库中有哪些DBA用户? select
- 我就废话不多说了,大家还是直接看代码吧!import cv2# 读取图片并缩放方便显示img = cv2.imread('D:/6.
- 记录一次小白的tensorflow学习过程,也为有同样困扰的小白留下点经验。先说我出错和解决的过程。在做风格迁移实验时,使用预加载权重的VG
- 当使用MySQL做站点的时候,肯定会有不知道的错误发生,怎么记录呢?以下是具体解决方法:class.method //建立错误日志 func
- 曾经为看别人写的杂乱代码而头痛吗?曾经为看BWindow代码而烦恼吗?曾经为减小JS体积和JS的可读性之间的矛盾而左右徘徊吗?最好的办法是有
- python 绘制拟合曲线并加指定点标识import osimport numpy as npfrom scipy import logfr
- 原文: gradio.app/interface-s…1.全局状态例子来解释import gradio as grsc
- 本文实例讲述了php+mysqli使用面向对象方式更新数据库的方法,分享给大家供大家参考。具体实现方法如下:<?php//第一步:创建
- 可视性的问题几乎在每次不同产品的用户测试中都会出现:用户总是对页面的某些元素、功能视若无睹,或根本无视。基于此,对这个问题进行了一番小小的研
- 新建py文件,在里面写入Python代码,代码的功能是打印10次“Hello!”,将代码文件保存到桌面上:在命令行中运行Python脚本,并
- access中可以将文本中的数据轻松导入表中,mysql中用起来没那么方便,其实起来也很简单。首先将数据记录按行处理好用特定的字符分开如:“
- jQuery.sheet 是一个用于创建 Web 电子表格的 jQuery插件,其功能及界面风格和微软的 Excel 非常相似,使得用户不至
- 如何用OdbcRegTool组件来创建一个数据源?OdbcRegTool是一个免费组件,在服务器上安装后,就可以来创建一个数据源:<h
- 在sql语句中,如果查找某个文本字段值为空的可以用select * from 表 where 字段=''但是如果