このプログラムのアイデアは、学校で子供たちのための小さなゲームとして役立つことです、問題はあなたがanwser場合は、そのレベルに撃つif文のいずれかの質問は、アプリを実行し、例えば、最後のレベルへの答えは146466です。これにより、子供たちが最後までスキップすることができます。何か改良がありましたら、私たちはこれを異なる方法でフォーマットできます。まったく新しい構造があるかもしれません。この構造でPythonのif文を登録して終了できますか?
#For The the {Pha<n>tex} eyes only
#Tkinter
from tkinter import *
from tkinter import ttk
#Window
root = Tk()
#Procedure that contains instructions to our game
def answers(a):
#answer level 1 , change to number 2 question
if AnswerBox.get() == '1000'or AnswerBox.get()== '1,000':
LEVEL.configure(text= 'Level : 2')
Question.configure(text = 'What is 1000 + 250')
AnswerBox.delete(0 , 'end')
#answer to level 2 , change to number 3 question
if AnswerBox.get() == '1250'or AnswerBox.get() == '1,250':
LEVEL.configure(text = 'Level : 3')
Question.configure(text = 'what is 2000 + 900')
AnswerBox.delete(0 , 'end')
#answer to level 3 , change to number 4 question
if AnswerBox.get() == '2900'or AnswerBox.get()=='2,900' :
LEVEL.configure(text = 'Level : 4')
Question.configure(text = 'What is 2434 + 1009')
AnswerBox.delete(0 , 'end')
#answer to level 4 , change to number 5 question
if AnswerBox.get() == '3443'or AnswerBox.get() =='3,443':
LEVEL.configure(text = 'Level : 5')
Question.configure(text = 'What is 3020 + 2304')
AnswerBox.delete(0 , 'end')
#answer level 5 , change to number 6 question
if AnswerBox.get() == '5324'or AnswerBox.get() =='5,324':
LEVEL.configure(text = 'Level : 6')
Question.configure(text = 'What is 4291 + 2334')
AnswerBox.delete(0 , 'end')
#answer to level 6 , change to number 7 question
if AnswerBox.get() == '6625'or AnswerBox.get() =='6,625':
LEVEL.configure(text = 'Level : 7')
Question.configure(text = 'What is 56233 + 2334')
AnswerBox.delete(0 , 'end')
#answer to level 7, change to number 8 question
if AnswerBox.get() == '58567'or AnswerBox.get() =='58,567':
LEVEL.configure(text = 'Level : 8')
Question.configure(text = 'What is 56243 + 23674')
AnswerBox.delete(0 , 'end')
#answer to level 8 , change to number 9 question
if AnswerBox.get() == '79917'or AnswerBox.get() =='79,917':
LEVEL.configure(text = 'Level : 9')
Question.configure(text = 'What is 53403 + 82310')
AnswerBox.delete(0 , 'end')
#answer to level 9 , change to number 10 question
if AnswerBox.get() == '135713'or AnswerBox.get() =='135,713':
LEVEL.configure(text = 'Level : 10')
Question.configure(text = 'What is 56233 + 90233')
AnswerBox.delete(0 , 'end')
#answer to level 10, You Win :)
if AnswerBox.get() == '146,466'or AnswerBox.get() =='146466':
LEVEL.configure(text = 'You Have Finished :)')
Question.configure(text = 'You Are An Genius Panther -{Pha<n>tex}')
AnswerBox.delete(0 , 'end')
#Procedure that allows us to jump back to level 1
def restart(event):
Question.configure(text = 'What is 500 + 500')
LEVEL.configure(text ='Level : 1')
#Level Entry
LEVEL = Label(root, text ='Level : 1' , font = ' times 10 bold')
LEVEL.grid(row = 0 , column = 0 ,sticky =W)
#Default start off question
Question = ttk.Label(root , text = 'What is 500 + 500' , font = ' times 10 bold')
Question.grid(row = 1 , column = 0 , sticky = W)
#Anwser Entry
AnswerBox = ttk.Entry(root)
AnswerBox.grid(row = 2 , column = 0 , columnspan = 2 , sticky = W)
# submit Button
submit = ttk.Button(root, text = 'Submit')
submit.grid(row = 2, column = 2 , sticky = W)
submit.bind('<Button-1>' , answers)
#Restart button
Restart = ttk.Button(root , text = 'Restart')
Restart.grid(row = 2 , column = 3 , sticky = W)
Restart.bind('<Button-1>' , restart)
#Allowing our window to consistanly Loop through
root.mainloop()
問題は、ステートメントのいずれかに該当する場合、コードが実行されると、私はいわば「レベルで数学のゲームを作成する方法を把握することはできませんつまり、ブール論理のようですピックアップして実行しているコードを選択すると、それはかなり簡単で、私はちょうどそれを考えている以上、このコードは、数字が一致すればユーザーをレベルに撃ちます。つまり、146466
このコードを実行するには、写真とアイコンを削除する必要があります。あたかもドライブに含まれていないかのように見てください。 –
現在のレベルを含む変数を設定して確認することができます。 – Stephie
変数を設定し、回答が正しいレベル+ = 1であると答え、質問をレベルに対応する別の質問に変更しますか? –