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

實現(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編寫一個刷題練習(xí)系統(tǒng)的文章就介紹到這了,更多相關(guān)Python刷題練習(xí)系統(tǒng)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
ubuntu?20.04系統(tǒng)下如何切換gcc/g++/python的版本
這篇文章主要給大家介紹了關(guān)于ubuntu?20.04系統(tǒng)下如何切換gcc/g++/python版本的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用ubuntu具有一定的參考借鑒價值,需要的朋友可以參考下2023-12-12
關(guān)于keras中卷積層Conv2D的學(xué)習(xí)記錄
這篇文章主要介紹了關(guān)于keras中卷積層Conv2D的學(xué)習(xí)記錄,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02
pytorch cnn 識別手寫的字實現(xiàn)自建圖片數(shù)據(jù)
這篇文章主要介紹了pytorch cnn 識別手寫的字實現(xiàn)自建圖片數(shù)據(jù),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-05-05
Python中NameError: name ‘Image‘ is not&nb
本文主要介紹了Python中NameError: name ‘Image‘ is not defined的問題解決,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-06-06

