Added latex and cleaned wording on all basic_math generators

This commit is contained in:
lukew3
2020-12-17 22:18:50 -05:00
parent 9842169143
commit 42dd6c368c
8 changed files with 42 additions and 26 deletions

View File

@@ -1,14 +1,17 @@
from .__init__ import *
def absoluteDifferenceFunc(maxA=100, maxB=100):
def absoluteDifferenceFunc(maxA=100, maxB=100, style='raw'):
a = random.randint(-1 * maxA, maxA)
b = random.randint(-1 * maxB, maxB)
absDiff = abs(a - b)
problem = "Absolute difference between numbers " + \
str(a) + " and " + str(b) + " = "
solution = absDiff
if style == 'latex':
problem = "\\(|" + str(a) + "-" + str(b) + "|=\\)"
solution = f"\\({absDiff}\\)"
else:
problem = "|" + str(a) + "-" + str(b) + "|="
solution = absDiff
return problem, solution