Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- def getLow():
- print ''
- return int(raw_input("Enter low: "))
- def getHigh():
- return int(raw_input("Enter high: "))
- def makeProblems(low, high):
- print "Type \"stop\" as your answer to stop and \"reset\" to reset."
- stopBool = False
- wrongList = []
- while stopBool == False:
- num1 = randint(low,high)
- num2 = randint(0,10)
- response = raw_input(str(num1) + ' X ' + str(num2) + ' = ')
- answer = str(num1 * num2)
- problem = str(num1) + ' X ' + str(num2) + ' = ' + answer
- if response == answer:
- print "Well done!"
- elif response.lower() == 'stop':
- if wrongList == []:
- wrongList.append("None")
- print "\n" + "You got the following wrong: \n" + "\n".join(wrongList)
- print ''
- stopBool = True
- return False
- elif response.lower() == 'reset':
- return True
- else:
- print 'WRONG! The correct answer was: ' + answer
- wrongList.append(problem)
- def getNums():
- print ''
- numList = []
- while True:
- inputNum = raw_input("Enter one of the numbers. Type 'done' to continue: ")
- if inputNum.lower() == 'done':
- break
- else:
- numList.append(inputNum)
- print '\n' + "You have selected numbers: " + ", ".join(numList)
- return numList
- def makeSpecifs(x):
- print '\n' + "Type \"stop\" as your answer to stop and \"reset\" to reset."
- stopBool = False
- wrongList = []
- while stopBool == False:
- num1 = int(x[randint(0,len(x) - 1)])
- num2 = randint(0,10)
- response = raw_input(str(num1) + ' X ' + str(num2) + ' = ')
- answer = str(num1 * num2)
- problem = str(num1) + ' X ' + str(num2) + ' = ' + answer
- if response == answer:
- print "Well done!"
- elif response.lower() == 'stop':
- if wrongList == []:
- wrongList.append("None")
- print "\n" + "You got the following wrong: \n \n" + "\n".join(wrongList)
- print ''
- stopBool = True
- return False
- elif response.lower() == 'reset':
- return True
- else:
- print 'WRONG! The correct answer was: ' + answer
- wrongList.append(problem)
- running = True
- while running:
- print ''
- whatMode = raw_input('Which mode? (Range or Number): ')
- if whatMode.lower() == 'range':
- running = makeProblems(getLow(),getHigh())
- elif whatMode.lower() == 'number' or whatMode.lower() == 'num':
- running = makeSpecifs(getNums())
- #testestsetststestest
- #This comment made in neutron drive
Advertisement
Add Comment
Please, Sign In to add comment