基于Python編寫一個(gè)刷題練習(xí)系統(tǒng)
用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)文章
ubuntu?20.04系統(tǒng)下如何切換gcc/g++/python的版本
這篇文章主要給大家介紹了關(guān)于ubuntu?20.04系統(tǒng)下如何切換gcc/g++/python版本的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用ubuntu具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-12-12python實(shí)現(xiàn)簡(jiǎn)易猜數(shù)小游戲
大家好,本篇文章主要講的是python實(shí)現(xiàn)簡(jiǎn)易猜數(shù)小游戲,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2022-01-01pyqt5 實(shí)現(xiàn)在別的窗口彈出進(jìn)度條
今天小編就為大家分享一篇pyqt5 實(shí)現(xiàn)在別的窗口彈出進(jìn)度條,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-06-06關(guān)于keras中卷積層Conv2D的學(xué)習(xí)記錄
這篇文章主要介紹了關(guān)于keras中卷積層Conv2D的學(xué)習(xí)記錄,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02pytorch cnn 識(shí)別手寫的字實(shí)現(xiàn)自建圖片數(shù)據(jù)
這篇文章主要介紹了pytorch cnn 識(shí)別手寫的字實(shí)現(xiàn)自建圖片數(shù)據(jù),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-05-05Python中NameError: name ‘Image‘ is not&nb
本文主要介紹了Python中NameError: name ‘Image‘ is not defined的問題解決,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-06-06python中extend函數(shù)舉例詳解以及對(duì)比
Python中的extend函數(shù)是用于將一個(gè)列表的元素添加到另一個(gè)列表中,它會(huì)將第一個(gè)列表中的元素逐個(gè)添加到第二個(gè)列表的末尾,這篇文章主要給大家介紹了關(guān)于python中extend函數(shù)舉例詳解以及對(duì)比的相關(guān)資料,需要的朋友可以參考下2024-03-03