Skip to content

Instantly share code, notes, and snippets.

@sakamer71
Created September 13, 2015 14:45
Show Gist options
  • Save sakamer71/1d42992538b55758d31d to your computer and use it in GitHub Desktop.
Save sakamer71/1d42992538b55758d31d to your computer and use it in GitHub Desktop.
template for ati creek
__author__ = '502400200'
from random import random,randint,randrange
pcount = 40
multrange = 13
divrange = 144
levels = list('ghijklmnopqrstuvwxyz')
print levels
def check_level():
level = raw_input("Choose a Level: ")
while level not in levels:
level = raw_input( "Choose a valid level - {}: ".format(' '.join(levels)))
choice = levels.index(level)
return choice
def eq_add(pcount,choice):
addrange = 13
addmax = int(6 + 1.2*choice)
min = 1
max = addrange - ((22-choice)/3)
for i in range(pcount):
while True:
a = randint(1,max)
b = randint(1,max)
if addmax >= a+b:
print "{} + {} = ".format(a,b)
break
def eq_subtract(pcount,choice):
subrange = 20
mymin = 1
mymax = 5 + choice
for i in range(pcount):
a = randint(mymin,mymax)
b = randint(mymin,mymax)
print "{} - {}".format(max(a,b), min(a,b))
def eq_multiply(pcount,choice):
pass
def eq_divide(pcount,choice):
pass
def choose_operator():
operators = ('+','-','*','/')
while True:
operator = raw_input("Choose an operator: {}".format(' '.join(operators)))
if operator in operators:
print "you selected {}".format(operator)
break
return operator
##MAIN
operator = choose_operator()
choice = check_level()
if operator == '+':
eq_add(pcount,choice)
elif operator == '-':
eq_subtract(pcount,choice)
elif operator == '*':
eq_multiply(pcount,choice)
elif operator == '/':
eq_divide(pcount,choice)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment