from sys import exit
from random import randint
lettersL = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
lettersU = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
symbols = [',','.','/',';','[',']','=','-','<','>','"','?',':','{','}','|','+','_',')','(','*','&','^','%','$','#','@','!','`','~']
print """
Welcome to simple maths training!
You will be tested on simple maths equations.
Note; Answers should only contain numbers.
"""
print "Choose your difficulty! (Easy/Medium/Hard)"
mode = raw_input("> ")
class Game(object):
def question(self): #Loop
while "easy" or "Easy" or "EASY" in mode:
f1 = randint(1,10) #SIMPLIFY THIS
f2 = randint(1,10) #SIMPLIFY THIS
print "What is %r + %r?" % (f1, f2)
answerIn = "%s" % (f1 + f2) #SIMPLIFY THIS
answer = raw_input("> ") #SIMPLIFY THIS
if lettersL[0-25] or lettersU[0-25] or symbols[0-29] in answer:
print "Numbers Only!"
elif answer != (f1+f2):
print "Wrong!"
if answer == answerIn:
print "Correct!"
elif lettersL[0-25] or lettersU[0-25] or symbols[0-29] in answer:
print "Numbers Only!"
elif answer != (f1+f2):
print "Wrong!"
if "easy" or "Easy" or "EASY" in mode:
new_game = Game()
new_game.question()
else:
"Sorry, I didn't understand that. try again!"
Very sloppy, I know. I'm a beginner.

New Topic/Question
Reply



MultiQuote





|