add latex to 28

This commit is contained in:
lukew3
2020-12-17 21:18:27 -05:00
parent 1a449f80d1
commit 4aec1db29a
3 changed files with 125 additions and 118 deletions

View File

@@ -1,7 +1,7 @@
from .__init__ import *
def multiplyFractionsFunc(maxVal=10):
def multiplyFractionsFunc(maxVal=10, style='raw'):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
c = random.randint(1, maxVal)
@@ -26,9 +26,16 @@ def multiplyFractionsFunc(maxVal=10):
if (tmp_d == 1 or tmp_d == gcd):
x = f"{tmp_n//gcd}"
problem = f"({a}/{b})*({c}/{d})"
solution = x
if style == 'latex':
problem = f"\\(\\frac{{{a}}}{{{b}}}\\cdot\\frac{{{c}}}{{{d}}}=\\)"
if (tmp_d == 1 or tmp_d == gcd):
solution = f"\\(\\frac{{{tmp_n}}}{{{gcd}}}\\)"
else:
solution = f"\\(\\frac{{{tmp_n//gcd}}}{{{tmp_d//gcd}}}\\)"
else:
problem = f"({a}/{b})*({c}/{d})"
solution = x
return problem, solution