Merge pull request #6 from samudoria/samu_b

Added multiplication and division
This commit is contained in:
Luke Weiler
2020-10-14 13:18:02 -04:00
committed by GitHub

View File

@@ -35,9 +35,27 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99):
solution = str(c) solution = str(c)
return problem, solution return problem, solution
def multiplicationFunc(maxRes = 99, maxMulti = 99):
a = random.randint(0, maxMulti)
b = random.randint(0, min(maxRes, maxMulti))
c = a*b
problem = str(a) + "*" + str(b) + "="
solution = str(c)
return problem, solution
def divisionFunc(maxRes = 99, maxDivid = 99):
a = random.randint(0, maxDivid)
b = random.randint(0, min(maxRes, maxDivid))
c = a/b
problem = str(a) + "/" + str(b) + "="
solution = str(c)
return problem, solution
# || Class Instances # || Class Instances
#Format is: #Format is:
#<title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>) #<title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>)
addition = Generator("Addition", 2, "a+b=", "c", additionFunc) addition = Generator("Addition", 2, "a+b=", "c", additionFunc)
subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc)
multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc)
division = Generator("Division", 5, "a/b=", "c", divisionFunc)