基于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


猜你喜欢
- 抽象方法和抽象类 在OOP 语言中,一个类可以有一个或多个子类,而每个类都有至少一个公有方法做为 外部代码访问其的接口。而抽象方法就是为了方
- Tips:for range创建了每个元素的副本,而不是直接返回每个元素的引用例子1:package mainimport "fm
- JS继承 JavaScript中没有类的概念,与类相关的继承的概念更是无从谈起,但是我们可以通过特殊的语法来 模拟面向对象语言中的继承。 在
- Excel中的一些概念一个excel文件中可以包含多个sheet,一个sheet可以理解成一个表格表格的每一行称为 Row表格的每一行中的任
- 首先介绍下怎么发现的吧, 线上的项目日志是通过 logging 模块打到 syslog 里, 跑了一段时间后发现 syslog 的 UDP
- --重命名表 rename table t_softwareport to software_port; --建立外键 alter tabl
- Python pip安装lxml出错的问题解决办法1. 在使用pip安装lxml过程中出现了一下错误: &
- 文件操作示例#输入文件f = open(r'D:\Python27\pro\123.bak') #输出文件fw = open
- 这篇文章主要介绍了如何基于Python制作有道翻译小工具,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的
- 企业管理器中的Tools,Database Maintenance Planner,可以设置数据库的定期自动备份计划。并
- 这篇博客将介绍如何使用OpenCV和深度学习应用全面嵌套的边缘检测。并将对图像和视频流应用全面嵌套边缘检测,然后将结果与OpenCV的标准C
- 本文实例为大家分享了vue-week-picker实现按周切换的日历的具体代码,供大家参考,具体内容如下vue-week-picker安装n
- Go(又称Golang)是Google开发的一种静态强类型、编译型、并发型,并具有垃圾回收功能的编程语言。下载Go语言开发包大家可以在Go语
- 1、Function 函数编程中,需要重复写的功能,可以包装成一个函数1)定义函数定义函数之前,实现给一个字符串增加前缀和后缀的操作:f1
- 跨文件使用全局变量有多个py文件同时使用一个全局变量时,那应该如何使跨文件,用这个全局变量呢?1. 错误示范file1.py代码如下:num
- 前言:keras默认提供了如何获取某一个层的某一个节点的输出,但是没有提供如何获取某一个层的输出的接口,所以有时候我们需要获取某一个层的输出
- 修改/etc/my.cnf或者/etc/mysql/my.cnf文件[client]default-character-set = utf8
- Pillow图片格式转换Pillow 库支持多种图片格式,您可以直接使用 open() 方法来读取图片,并且无须考虑图片是何种类型。Pill
- 一、PyPicGoPyPicGo 是一款图床工具,是PicGo是Python版实现,并支持各种插件自定义插件,目前PyPicGo自带了git
- Turtle库是Python内置的图形化模块,属于标准库之一,位于Python安装目录的lib文件夹下,常用函数有以下几种:画笔控制函数pe