OK i have this code below here...it works fine. play with it and you will learn its a simple maths game but i want to add substraction to it as well. i want it to be able to load the program up and then be able to choose from addition as well as substraction like a button for each on start up or something.

Please can anyone help me! Really urgent! Please!

from Tkinter import *
import tkMessageBox
import random

def ask():
    global num1 
    num1 = random.randint(1, 100)
    global num2 
    num2 = random.randint(1, 100)
    global answer 
    answer = num1 + num2
    label1.config(text='What is ' + str(num1) + '+' + str(num2) + '?')

    # put the cursor into the Enter-Box
    entry1.focus_set()
    
def checkAnswer():
    mainAnswer = entry1.get()
    
    # if empty give message
    if len(mainAnswer) == 0:
        tkMessageBox.showwarning(message='Need to enter some numbers!')
        return
    if int(mainAnswer) != answer:
        tkMessageBox.showwarning(message='The correct answer is: ' + str(answer))
    else:
        tkMessageBox.showinfo(message='Correct! :)')

#set the window
root = Tk()
root.title("Mikey's Multiplication Quiz")
root.geometry('500x500')

# welcome message
label2 = Label(root, text="Hi!\n  Let's do some Mathematics problems!")
label2.config(font=('times', 18, 'bold'), fg='black', bg='white')
label2.grid(row=0, column=0)

#add label
label1 = Label(root)
label1.grid(row=2, column=0)

#entry
entry1 = Entry(root)
entry1.grid(row=3, column=0)

# bind the return key
entry1.bind('<Return>', func=lambda e:checkAnswer())

#button
askBtn = Button(root, text='Ask Me a Question!', command=ask)
askBtn.grid(row=4, column=0)

okButton = Button(root, text='OK', command=checkAnswer)
okButton.grid(row=4, column=1)

root.mainloop()

i want it to be able to load the program up and then be able to choose from addition as well as substraction like a button for each on start up or something.

What if you had a radio button choice. So that addition and subtraction could be chosen dynamically. The user could try a few additions, and then go to subtraction if they wanted.
If you want to force them to perform the same ops for the entirety of the game, then another option would be to have a message box pop up when the program starts with two buttons, addition or subtraction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.