Math Game

View: New views
1 Messages — Rating Filter:   Alert me  

Math Game

by Kid Programmer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey guys.  I am making a game with python in which you are trying to answer math questions.  The program asks for input for the answers to questions.  My problem is that it is constantly able to receive input during the program so for example when it is printing how many questions you got right someone could type in stuff.  So if you had 0 right and it print "0 were right" you could type in a 1 and it would be "10 were right"  Here is my source to it:


# Welcome To The Math Game
from time import sleep
print "Loading"
sleep(3)
print "Welcome To The Math Game."
#Rules
from time import sleep
sleep(2)
print "Just answer the problems as well as you can and do not use a calculator."
from time import sleep
sleep(2)
print "At the end you will get your score."
from time import sleep
sleep(2)
print "You will be asked 4 problems one multiplication one adding one subtracting and one dividing."
from time import sleep
sleep(2)
print "Lets Start."
# Start It
answer0 = 0
if answer0 == 0:
    answersright = 0
else:
    starting_variable = 0
# Problem1
print "34*32"
answer1 = input()

if answer1 == 1088:
    answersright=answersright+1
    q1=1
else:
    answersright=answersright
    q1=0
#problem 2
print "234/13"
answer2 = input()
if answer2 == 18:

    answersright = answersright+1
    q2=1
else:
    answersright=answersright
    q2=0
#problem 3
print "412+2345"
answer3 = input()
if answer3 == 2768:
    answersright = answersright+1
    q3=1
else:
    answersright=answersright
    q3=0
#problem 4
print "234-2548"
answer4 = input()
if answer4 == -2314:
    answersright=answersright+1
    q4=1
else:
    answersright=answersright
    q4=0
#End Of Problems
print "Congratulations you just finished the math game"
print "You will now receive your score"
print "Calculating"
from time import sleep
sleep(3)
if answersright == 0:
    print "0 problems were right.  You can do better."
else:
    blank_else=0
if answersright == 1:
    print"1 problem was right.  Try harder next time"
else:
    blank_else=0
if answersright == 2:
    print "2 problems were right.  Try harder next time and get that extra two."
else:
    blank_else=0
if answersright == 3:
    print "3 problems were right.  Try a bit harder and you can have 100%."
else:
    blank_else=0
if answersright == 4:
    print "4 right.  Great job keep it up!"
    problem0 = 0
else:
    blank_else=0
if q1>0:
    from time import sleep
    print "Calculating..."
    sleep(2)
    print "You got question 1 right"
else:
    from time import sleep
    print "Calculating..."
    sleep (2)
    print "You got question 1 wrong"
if q2>0:
    from time import sleep
    print "Calculating..."
    sleep(2)
    print "You got question 2 right"
else:
    from time import sleep
    print "Calculating..."
    sleep(2)
    print "You got question 2 wrong"
if q3>0:
    from time import sleep
    print"Calculating..."
    sleep(2)
    print "You got question 3 right"
else:
    from time import sleep
    sleep(2)
    print "Calculating..."
    print "You got question 3 wrong"
if q4>0:
    from time import sleep
    print "Calculating..."
    sleep(2)
    print "You got question 4 right"
else:
    from time import sleep
    print "Calculating..."
    sleep(2)
    print "You got question 4 wrong"
   
P.S.  The reason I put in "loading" and "calculating" was just for fun.
LightInTheBox - Buy quality products at wholesale price!