Added multiplication and division

This commit is contained in:
samuele
2020-10-14 17:48:31 +02:00
parent 4aa2e021b3
commit dc3e40bafe

View File

@@ -35,9 +35,27 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99):
solution = str(c)
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
#Format is:
#<title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>)
addition = Generator("Addition", 2, "a+b=", "c", additionFunc)
subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc)
multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc)
division = Generator("Division", 5, "a/b=", "c", divisionFunc)