基于Python怎么编写一个刷题练习系统
作者:吹吹风会发光
时间:2023-05-14
来源:互联网
浏览:0
实现效果实现代码选择题defxuanze():globalflag2ifflag2==1:definsert():num=var1.get()question=var2.get()choice=var3.get()answer=var4.get()withopen('d:\\练习系统\\练习三3.1.pickle','rb')asfile:lst1=pickle.load(file)withopen('d:\\练习系统\\练习三3.2.pickle',
实现效果

实现代码
选择题
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()
作者最新文章
PDF怎么取消密码保护?4种解锁方法整理
2026-09-08 18:23
三星 Galaxy Z Fold8 内屏边角支撑偏软?实测与官方回应
2026-09-08 16:39
手机Excel表格制作教程:小屏幕高效录入与格式调整指南
2026-09-04 09:27
PDF文档按页转换成图片怎么做?在线转换步骤整理
2026-09-03 11:06
PDF转Excel操作指南:在线工具、Adobe与Excel内置功能详解
2026-09-02 19:08
上一篇:
MySQL查询怎么主键
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多
Windows 10
Windows
Windows 10 是一款微软推出的经典操作系统,拥有硬件兼容性与多任务处理能力。它更偏向把系统状态查看和常用调节动作放在一起,适合需要持续观察和微调设备状态的场景。
极度公式
Windows/macOS/Linux
极度公式是一款跨平台专业LaTeX公式识别编辑软件,支持OCR公式识别和多平台编辑。和使用说明,避免使用,享受完整功能与稳定支持。做扫描整理、文字提取和表格转换时,它能把识别后的处理步骤接得更顺,资料录入这类场景会省下不少时间。
















