基于Python編寫一個(gè)刷題練習(xí)系統(tǒng)
更新時(shí)間:2023年02月21日 09:16:41 作者:Want595
這篇文章主要為大家詳細(xì)介紹了如何基于Python語(yǔ)言編寫一個(gè)簡(jiǎn)單的刷題練習(xí)系統(tǒng),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
用python給自己做個(gè)練習(xí)系統(tǒng)刷題吧!
實(shí)現(xiàn)效果

實(shí)現(xiàn)代碼
選擇題
def xuanze():
global flag2
if flag2==1:
def insert():
num=var1.get()
question=var2.get()
choice=var3.get()
answer=var4.get()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.3.pickle','rb') as file:
lst3=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三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:\\練習(xí)系統(tǒng)\\練習(xí)三3.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三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:\\練習(xí)系統(tǒng)\\練習(xí)三3.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.3.pickle','rb') as file:
lst3=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三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:\\練習(xí)系統(tǒng)\\練習(xí)三3.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三3.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)三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:\\練習(xí)系統(tǒng)\\練習(xí)一1.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一1.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一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:\\練習(xí)系統(tǒng)\\練習(xí)一1.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一1.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一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:\\練習(xí)系統(tǒng)\\練習(xí)一1.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一1.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一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:\\練習(xí)系統(tǒng)\\練習(xí)一1.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一1.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)一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:\\練習(xí)系統(tǒng)\\練習(xí)二2.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二2.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二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:\\練習(xí)系統(tǒng)\\練習(xí)二2.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二2.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二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:\\練習(xí)系統(tǒng)\\練習(xí)二2.1.pickle','rb') as file:
lst1=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二2.2.pickle','rb') as file:
lst2=pickle.load(file)
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二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:\\練習(xí)系統(tǒng)\\練習(xí)二2.1.pickle','wb') as file:
pickle.dump(lst1,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二2.2.pickle','wb') as file:
pickle.dump(lst2,file)
file.close()
with open('d:\\練習(xí)系統(tǒng)\\練習(xí)二2.3.pickle','wb') as file:
pickle.dump(lst3,file)
file.close()到此這篇關(guān)于基于Python編寫一個(gè)刷題練習(xí)系統(tǒng)的文章就介紹到這了,更多相關(guān)Python刷題練習(xí)系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解Python中Pytest和Unittest的區(qū)別
Pytest?和?Unittest是Python中屬于最常用的兩個(gè)測(cè)試框架。那么他們有些什么區(qū)別呢??Playwright?為什么只給了Pytest的深度支持,而不是Unittest呢?本文就來(lái)和大家詳細(xì)聊聊2023-03-03
python3 selenium自動(dòng)化測(cè)試 強(qiáng)大的CSS定位方法
今天小編就為大家分享一篇python3 selenium自動(dòng)化測(cè)試 強(qiáng)大的CSS定位方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-08-08
如何通過(guò)Python3和ssl實(shí)現(xiàn)加密通信功能
這篇文章主要介紹了如何通過(guò)Python3和ssl實(shí)現(xiàn)加密通信功能,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-05-05
解決安裝Python的第三方庫(kù)pandas報(bào)錯(cuò)問題
這篇文章主要介紹了解決安裝Python的第三方庫(kù)pandas報(bào)錯(cuò)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-08-08

