mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
added latex unavailable message and scripts folder
This commit is contained in:
@@ -60,7 +60,7 @@ This creates the pdf `ws.pdf` in your current directory
|
|||||||
|
|
||||||
* `genById(id)` generates a problem, solution set with generator id `id` in the format `[problem, solution]`
|
* `genById(id)` generates a problem, solution set with generator id `id` in the format `[problem, solution]`
|
||||||
|
|
||||||
* Pass the kwarg `format=latex` to return problem and solution set as latex. If latex is not available for that generator, the problem will be returned as raw data.
|
* Pass the kwarg `format=latex` to return problem and solution set as latex. If latex is not available for that generator, the problem will return the string "Latex unavailable"
|
||||||
|
|
||||||
* Pass the kwarg `format=raw` to return just the raw data for each generator. An array of each variable necessary to the generator is returned.
|
* Pass the kwarg `format=raw` to return just the raw data for each generator. An array of each variable necessary to the generator is returned.
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ def likeTermCombineFunc(maxCoef=10, maxExp=20, maxTerms=10, format='string'):
|
|||||||
solution = combineTerms(problem)
|
solution = combineTerms(problem)
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ def compoundInterestFunc(maxPrinciple=10000,
|
|||||||
str(p) + " dollars, " + str(r) + \
|
str(p) + " dollars, " + str(r) + \
|
||||||
"% rate of interest and for a time period of " + str(n) + " year is = "
|
"% rate of interest and for a time period of " + str(n) + " year is = "
|
||||||
return problem, str(a)
|
return problem, str(a)
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return p, r, n, a
|
return p, r, n, a
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ def distanceTwoPointsFunc(maxValXY=20, minValXY=-20, format='string'):
|
|||||||
solution = f"sqrt({distanceSq})"
|
solution = f"sqrt({distanceSq})"
|
||||||
problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})"
|
problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return point1X, point1Y, point2X, point2Y, distanceSq
|
return point1X, point1Y, point2X, point2Y, distanceSq
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ def expandingFunc(range_x1=10,
|
|||||||
problem = f"({p1}x{p2})({p3}x{p4})"
|
problem = f"({p1}x{p2})({p3}x{p4})"
|
||||||
solution = f"{c1}*x^2{c2}*x{c3}"
|
solution = f"{c1}*x^2{c2}*x{c3}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return p1, p2, p3, p4, c1, c2, c3
|
return p1, p2, p3, p4, c1, c2, c3
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ def factoringFunc(range_x1=10, range_x2=10, format='string'):
|
|||||||
x2 = intParser(x2)
|
x2 = intParser(x2)
|
||||||
solution = f"(x{x1})(x{x2})"
|
solution = f"(x{x1})(x{x2})"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return b, c, x1, x2
|
return b, c, x1, x2
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ def determinantToMatrix22(maxMatrixVal=100, format='string'):
|
|||||||
problem = f"Det([[{a}, {b}], [{c}, {d}]]) = "
|
problem = f"Det([[{a}, {b}], [{c}, {d}]]) = "
|
||||||
solution = f" {determinant}"
|
solution = f" {determinant}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c, d, determinant
|
return a, b, c, d, determinant
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ def intersectionOfTwoLinesFunc(minM=-10,
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return equation1, equation2, solution
|
return equation1, equation2, solution
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ def matrixInversion(SquareMatrixDimension=3,
|
|||||||
problem = 'Inverse of Matrix ' + str(Mat) + ' is:'
|
problem = 'Inverse of Matrix ' + str(Mat) + ' is:'
|
||||||
solution = str(sympy.Matrix.inv(Mat))
|
solution = str(sympy.Matrix.inv(Mat))
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return Mat, sympy.Matrix.inv(Mat)
|
return Mat, sympy.Matrix.inv(Mat)
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ def linearEquationsFunc(n=2, varRange=20, coeffRange=20, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ def logFunc(maxBase=3, maxVal=8, format='string'):
|
|||||||
return problem, solution
|
return problem, solution
|
||||||
elif format == 'latex':
|
elif format == 'latex':
|
||||||
problem = "\\(\\log_{" + str(b) + "}" + str(c) + "\\)"
|
problem = "\\(\\log_{" + str(b) + "}" + str(c) + "\\)"
|
||||||
print(problem)
|
|
||||||
solution = "\\(" + str(a) + "\\)"
|
solution = "\\(" + str(a) + "\\)"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ def matrixMultiplicationFunc(maxVal=100, max_dim=10, format='string'):
|
|||||||
problem = f"Multiply \n{a_string}\n and \n\n{b_string}"
|
problem = f"Multiply \n{a_string}\n and \n\n{b_string}"
|
||||||
solution = matrixMultiplicationFuncHelper(res)
|
solution = matrixMultiplicationFuncHelper(res)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a_string, b_string, res
|
return a_string, b_string, res
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ def MidPointOfTwoPointFunc(maxValue=20, format='string'):
|
|||||||
problem = f"({x1},{y1}),({x2},{y2})="
|
problem = f"({x1},{y1}),({x2},{y2})="
|
||||||
solution = f"({xm},{ym})"
|
solution = f"({xm},{ym})"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return x1, y1, x2, y2, xm, ym
|
return x1, y1, x2, y2, xm, ym
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,13 @@ def multiplyComplexNumbersFunc(minRealImaginaryNum=-20,
|
|||||||
num2 = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum),
|
num2 = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum),
|
||||||
random.randint(minRealImaginaryNum, maxRealImaginaryNum))
|
random.randint(minRealImaginaryNum, maxRealImaginaryNum))
|
||||||
product = num1 * num2
|
product = num1 * num2
|
||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"{num1} * {num2} = "
|
problem = f"{num1} * {num2} = "
|
||||||
solution = str(product)
|
solution = str(product)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return num1, num2, product
|
return num1, num2, product
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100, format='string'):
|
|||||||
problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = "
|
problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = "
|
||||||
solution = f"[[{a1},{b1}],[{c1},{d1}]]"
|
solution = f"[[{a1},{b1}],[{c1},{d1}]]"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
elif style == 'latex':
|
elif format == 'latex':
|
||||||
problem = "\\(" + str(constant) + "\\cdot\\begin{bmatrix}" + str(
|
problem = "\\(" + str(constant) + "\\cdot\\begin{bmatrix}" + str(
|
||||||
a) + "&" + str(b) + "\\\\" + str(c) + "&" + str(
|
a) + "&" + str(b) + "\\\\" + str(c) + "&" + str(
|
||||||
d) + "\\end{bmatrix}=\\)"
|
d) + "\\end{bmatrix}=\\)"
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ def quadraticEquation(maxVal=100, format='string'):
|
|||||||
a, b, c)
|
a, b, c)
|
||||||
solution = str(res)
|
solution = str(res)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c, res
|
return a, b, c, res
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ def simpleInterestFunc(maxPrinciple=10000,
|
|||||||
c) + " years is = "
|
c) + " years is = "
|
||||||
solution = str(d)
|
solution = str(d)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c, d
|
return a, b, c, d
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ def systemOfEquationsFunc(range_x=10,
|
|||||||
problem = f"{coeffToFuncString(new_c1)}, {coeffToFuncString(new_c2)}"
|
problem = f"{coeffToFuncString(new_c1)}, {coeffToFuncString(new_c2)}"
|
||||||
solution = f"x = {x}, y = {y}"
|
solution = f"x = {x}, y = {y}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return new_c1, new_c2, x, y
|
return new_c1, new_c2, x, y
|
||||||
# Add random (non-zero) multiple of equations to each other
|
# Add random (non-zero) multiple of equations to each other
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ def vectorCrossFunc(minVal=-20, maxVal=20, format='string'):
|
|||||||
problem = str(a) + " X " + str(b) + " = "
|
problem = str(a) + " X " + str(b) + " = "
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c
|
return a, b, c
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def vectorDotFunc(minVal=-20, maxVal=20, format='string'):
|
|||||||
problem = str(a) + " . " + str(b) + " = "
|
problem = str(a) + " . " + str(b) + " = "
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c
|
return a, b, c
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def factorialFunc(maxInput=6, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return str(a) + "! = ", str(b)
|
return str(a) + "! = ", str(b)
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b
|
return a, b
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ def isprime(max_num=100, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, solution
|
return a, solution
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def percentageFunc(maxValue=99, maxpercentage=99, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, formatted_float
|
return a, b, formatted_float
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def subtractionFunc(maxMinuend=99, maxDiff=99, format='string'):
|
|||||||
problem = str(a) + "-" + str(b) + "="
|
problem = str(a) + "-" + str(b) + "="
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c
|
return a, b, c
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ def definiteIntegralFunc(max_coeff=100, format='string'):
|
|||||||
str(a) + "x^2 + " + str(b) + "x + " + str(c) + " is = "
|
str(a) + "x^2 + " + str(b) + "x + " + str(c) + " is = "
|
||||||
solution = str(S)
|
solution = str(S)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c, S
|
return a, b, c, S
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ def differentiationFunc(diff_lvl=2, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ def powerRuleDifferentiationFunc(maxCoef=10,
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ def powerRuleIntegrationFunc(maxCoef=10,
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ def stationaryPointsFunc(maxExp=3, maxCoef=10, format='string'):
|
|||||||
problem = 'f(x)=' + str(problem).replace('**', '^')
|
problem = 'f(x)=' + str(problem).replace('**', '^')
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ def BCDtoDecimalFunc(maxNumber=10000, format='string'):
|
|||||||
problem = "Integer of Binary Coded Decimal " + str(n) + " is = "
|
problem = "Integer of Binary Coded Decimal " + str(n) + " is = "
|
||||||
solution = int(binstring, 2)
|
solution = int(binstring, 2)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return n, int(binstring, 2)
|
return n, int(binstring, 2)
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ def binary2sComplementFunc(maxDigits=10, format='string'):
|
|||||||
problem = "2's complement of " + question + " ="
|
problem = "2's complement of " + question + " ="
|
||||||
solution = ''.join(answer).lstrip('0')
|
solution = ''.join(answer).lstrip('0')
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return question, answer
|
return question, answer
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ def binaryComplement1sFunc(maxDigits=10, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = question + "="
|
problem = question + "="
|
||||||
return problem, answer
|
return problem, answer
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, answer
|
return problem, answer
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def binaryToDecimalFunc(max_dig=10, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
solution = int(problem, 2)
|
solution = int(problem, 2)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def binaryToHexFunc(max_dig=10, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
solution = hex(int(problem, 2))
|
solution = hex(int(problem, 2))
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,14 @@ def DecimalToBCDFunc(maxNumber=10000, format='string'):
|
|||||||
bcdstring = str(nibble) + bcdstring
|
bcdstring = str(nibble) + bcdstring
|
||||||
x >>= 4
|
x >>= 4
|
||||||
|
|
||||||
|
if format == 'string':
|
||||||
problem = "BCD of Decimal Number " + str(n) + " is = "
|
problem = "BCD of Decimal Number " + str(n) + " is = "
|
||||||
solution = int(bcdstring)
|
solution = bcdstring
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
|
else:
|
||||||
|
return n, int(bcdstring)
|
||||||
|
|
||||||
|
|
||||||
decimal_to_bcd = Generator("Decimal to Binary Coded Decimal", 103,
|
decimal_to_bcd = Generator("Decimal to Binary Coded Decimal", 103,
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ def DecimalToBinaryFunc(max_dec=99, format='string'):
|
|||||||
a = random.randint(1, max_dec)
|
a = random.randint(1, max_dec)
|
||||||
b = bin(a).replace("0b", "")
|
b = bin(a).replace("0b", "")
|
||||||
|
|
||||||
|
if format == 'string':
|
||||||
problem = "Binary of " + str(a) + "="
|
problem = "Binary of " + str(a) + "="
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
|
else:
|
||||||
|
return a, str(b)
|
||||||
|
|
||||||
decimal_to_binary = Generator("Decimal to Binary", 14, DecimalToBinaryFunc,
|
decimal_to_binary = Generator("Decimal to Binary", 14, DecimalToBinaryFunc,
|
||||||
["max_dec=99"])
|
["max_dec=99"])
|
||||||
|
|||||||
@@ -4,10 +4,15 @@ from .__init__ import *
|
|||||||
def deciToHexaFunc(max_dec=1000, format='string'):
|
def deciToHexaFunc(max_dec=1000, format='string'):
|
||||||
a = random.randint(0, max_dec)
|
a = random.randint(0, max_dec)
|
||||||
b = hex(a)
|
b = hex(a)
|
||||||
|
|
||||||
|
if format == 'string':
|
||||||
problem = "Binary of " + str(a) + "="
|
problem = "Binary of " + str(a) + "="
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
|
else:
|
||||||
|
return a, str(b)
|
||||||
|
|
||||||
|
|
||||||
decimal_to_hexadeci = Generator("Decimal to Hexadecimal", 79, deciToHexaFunc,
|
decimal_to_hexadeci = Generator("Decimal to Hexadecimal", 79, deciToHexaFunc,
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ def decimalToOctalFunc(maxDecimal=4096, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return x, oct(x)
|
return x, oct(x)
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ def fibonacciSeriesFunc(minNo=1, format='string'):
|
|||||||
problem = "The Fibonacci Series of the first " + str(
|
problem = "The Fibonacci Series of the first " + str(
|
||||||
n) + " numbers is ?"
|
n) + " numbers is ?"
|
||||||
return problem, fibList
|
return problem, fibList
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return n, fibList
|
return n, fibList
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def moduloFunc(maxRes=99, maxModulo=99, format='string'):
|
|||||||
problem = str(a) + "%" + str(b) + "="
|
problem = str(a) + "%" + str(b) + "="
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c
|
return a, b, c
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,9 @@ def nthFibonacciNumberFunc(maxN=100, format='string'):
|
|||||||
ans = int((math.pow(golden_ratio, n) - math.pow(-golden_ratio, -n)) / (math.sqrt(5)))
|
ans = int((math.pow(golden_ratio, n) - math.pow(-golden_ratio, -n)) / (math.sqrt(5)))
|
||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
solution = f"{ans}"
|
return problem, str(ans)
|
||||||
return problem, solution
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return n, ans
|
return n, ans
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,23 @@ def angleBtwVectorsFunc(maxEltAmt=20, format='string'):
|
|||||||
|
|
||||||
mags = math.sqrt(sum([i**2
|
mags = math.sqrt(sum([i**2
|
||||||
for i in v1])) * math.sqrt(sum([i**2 for i in v2]))
|
for i in v1])) * math.sqrt(sum([i**2 for i in v2]))
|
||||||
problem = f"angle between the vectors {v1} and {v2} is:"
|
|
||||||
solution = ''
|
solution = ''
|
||||||
|
ans = 0
|
||||||
try:
|
try:
|
||||||
solution = str(round(math.acos(s / mags), 2)) + " radians"
|
ans = round(math.acos(s / mags), 2)
|
||||||
|
solution = str(ans) + " radians"
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print('angleBtwVectorsFunc has some issues with math module, line 16')
|
print('angleBtwVectorsFunc has some issues with math module, line 16')
|
||||||
solution = 'NaN'
|
solution = 'NaN'
|
||||||
|
ans = 'NaN'
|
||||||
# would return the answer in radians
|
# would return the answer in radians
|
||||||
|
if format == 'string':
|
||||||
|
problem = f"angle between the vectors {v1} and {v2} is:"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
|
else:
|
||||||
|
return v1, v2, ans
|
||||||
|
|
||||||
|
|
||||||
angle_btw_vectors = Generator("Angle between 2 vectors", 70,
|
angle_btw_vectors = Generator("Angle between 2 vectors", 70,
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def regularPolygonAngleFunc(minVal=3, maxVal=20, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return sideNum, solution
|
return sideNum, solution
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ def arclengthFunc(maxRadius=49, maxAngle=359, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
solution = f"Arc length of the angle = {formatted_float}"
|
solution = f"Arc length of the angle = {formatted_float}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return radius, angle, formatted_float
|
return radius, angle, formatted_float
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def areaCircle(maxRadius=100, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"Area of circle with radius {r}"
|
problem = f"Area of circle with radius {r}"
|
||||||
return problem, str(area)
|
return problem, str(area)
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return r, area
|
return r, area
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20, format='string'):
|
|||||||
str(a) + " " + str(b) + " " + str(c) + " = "
|
str(a) + " " + str(b) + " " + str(c) + " = "
|
||||||
solution = str(area)
|
solution = str(area)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c, area
|
return a, b, c, area
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ def basicTrigonometryFunc(angles=[0, 30, 45, 60, 90],
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return function, angle, solution
|
return function, angle, solution
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def circumferenceCircle(maxRadius=100, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"Circumference of circle with radius {r}"
|
problem = f"Circumference of circle with radius {r}"
|
||||||
return problem, circumference
|
return problem, circumference
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return r, circumference
|
return r, circumference
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def curvedSurfaceAreaCylinderFunc(maxRadius=49, maxHeight=99, format='string'):
|
|||||||
problem = f"What is the curved surface area of a cylinder of radius, {r} and height, {h}?"
|
problem = f"What is the curved surface area of a cylinder of radius, {r} and height, {h}?"
|
||||||
solution = f"CSA of cylinder = {formatted_float}"
|
solution = f"CSA of cylinder = {formatted_float}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return r, h, formatted_float
|
return r, h, formatted_float
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def degreeToRadFunc(max_deg=360, format='string'):
|
|||||||
problem = "Angle " + str(a) + " in radians is = "
|
problem = "Angle " + str(a) + " in radians is = "
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b
|
return a, b
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ def fourthAngleOfQuadriFunc(maxAngle=180, format='string'):
|
|||||||
problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} ="
|
problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} ="
|
||||||
solution = angle4
|
solution = angle4
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return angle1, angle2, angle3, angle4
|
return angle1, angle2, angle3, angle4
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ def perimeterOfPolygons(maxSides=12, maxLength=120, format='string'):
|
|||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return size_of_sides, sides, solution
|
return size_of_sides, sides, solution
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def pythagoreanTheoremFunc(maxLength=20, format='string'):
|
|||||||
problem = f"The hypotenuse of a right triangle given the other two lengths {a} and {b} = "
|
problem = f"The hypotenuse of a right triangle given the other two lengths {a} and {b} = "
|
||||||
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
|
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, round(c, 2)
|
return a, b, round(c, 2)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def radianToDegFunc(max_rad=3, format='string'):
|
|||||||
problem = "Angle " + str(a) + " in degrees is = "
|
problem = "Angle " + str(a) + " in degrees is = "
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b
|
return a, b
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def sectorAreaFunc(maxRadius=49, maxAngle=359, format='string'):
|
|||||||
problem = f"Given radius, {r} and angle, {a}. Find the area of the sector."
|
problem = f"Given radius, {r} and angle, {a}. Find the area of the sector."
|
||||||
solution = f"Area of sector = {formatted_float}"
|
solution = f"Area of sector = {formatted_float}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return r, a, formatted_float
|
return r, a, formatted_float
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ def sumOfAnglesOfPolygonFunc(maxSides=12, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"Sum of angles of polygon with {side_count} sides = "
|
problem = f"Sum of angles of polygon with {side_count} sides = "
|
||||||
return problem, sum
|
return problem, sum
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return side_count, sum
|
return side_count, sum
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m', format='string'):
|
|||||||
problem = f"Surface area of cone with height = {a}{unit} and radius = {b}{unit} is"
|
problem = f"Surface area of cone with height = {a}{unit} and radius = {b}{unit} is"
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, ans, unit
|
return a, b, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def surfaceAreaCube(maxSide=20, unit='m', format='string'):
|
|||||||
problem = f"Surface area of cube with side = {a}{unit} is"
|
problem = f"Surface area of cube with side = {a}{unit} is"
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, ans, unit
|
return a, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def surfaceAreaCuboid(maxSide=20, unit='m', format='string'):
|
|||||||
problem = f"Surface area of cuboid with sides = {a}{unit}, {b}{unit}, {c}{unit} is"
|
problem = f"Surface area of cuboid with sides = {a}{unit}, {b}{unit}, {c}{unit} is"
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c, ans, unit
|
return a, b, c, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m', format='string'):
|
|||||||
problem = f"Surface area of cylinder with height = {a}{unit} and radius = {b}{unit} is"
|
problem = f"Surface area of cylinder with height = {a}{unit} and radius = {b}{unit} is"
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, ans, unit
|
return a, b, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def surfaceAreaSphere(maxSide=20, unit='m', format='string'):
|
|||||||
problem = f"Surface area of Sphere with radius = {r}{unit} is"
|
problem = f"Surface area of Sphere with radius = {r}{unit} is"
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return r, ans, unit
|
return r, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def thirdAngleOfTriangleFunc(maxAngle=89, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"Third angle of triangle with angles {angle1} and {angle2} = "
|
problem = f"Third angle of triangle with angles {angle1} and {angle2} = "
|
||||||
return problem, angle3
|
return problem, angle3
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return angle1, angle2, angle3
|
return angle1, angle2, angle3
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ def isTriangleValidFunc(maxSideLength=50, format='string'):
|
|||||||
else:
|
else:
|
||||||
solution = "No"
|
solution = "No"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return sideA, sideB, sideC, exists
|
return sideA, sideB, sideC, exists
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def volumeCone(maxRadius=20, maxHeight=50, unit='m', format='string'):
|
|||||||
problem = f"Volume of cone with height = {a}{unit} and radius = {b}{unit} is"
|
problem = f"Volume of cone with height = {a}{unit} and radius = {b}{unit} is"
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, ans, unit
|
return a, b, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def volumeCube(maxSide=20, unit='m', format='string'):
|
|||||||
problem = f"Volume of cube with side = {a}{unit} is"
|
problem = f"Volume of cube with side = {a}{unit} is"
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, ans, unit
|
return a, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ def volumeCuboid(maxSide=20, unit='m', format='string'):
|
|||||||
problem = f"Volume of cuboid with sides = {a}{unit}, {b}{unit}, {c}{unit} is"
|
problem = f"Volume of cuboid with sides = {a}{unit}, {b}{unit}, {c}{unit} is"
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, c, ans, unit
|
return a, b, c, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def volumeCylinder(maxRadius=20, maxHeight=50, unit='m', format='string'):
|
|||||||
problem = f"Volume of cylinder with height = {a}{unit} and radius = {b}{unit} is"
|
problem = f"Volume of cylinder with height = {a}{unit} and radius = {b}{unit} is"
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, ans, unit
|
return a, b, ans, unit
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def volumeSphereFunc(maxRadius=100, format='string'):
|
|||||||
problem = f"Volume of sphere with radius {r} m = "
|
problem = f"Volume of sphere with radius {r} m = "
|
||||||
solution = f"{ans} m^3"
|
solution = f"{ans} m^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return r, ans
|
return r, ans
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ def arithmeticProgressionSumFunc(maxd=100,
|
|||||||
problem = 'Find the sum of first ' + \
|
problem = 'Find the sum of first ' + \
|
||||||
str(n) + ' terms of the AP series: ' + apString
|
str(n) + ' terms of the AP series: ' + apString
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return n, apString, solution
|
return n, apString, solution
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ def arithmeticProgressionTermFunc(maxd=100,
|
|||||||
problem = 'Find the term number ' + str(
|
problem = 'Find the term number ' + str(
|
||||||
n) + ' of the AP series: ' + apString
|
n) + ' of the AP series: ' + apString
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return n, apString, solution
|
return n, apString, solution
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ def baseConversionFunc(maxNum=60000, maxBase=16, format='string'):
|
|||||||
fromBaseTenTo(n, bases[0]), bases[0], bases[1])
|
fromBaseTenTo(n, bases[0]), bases[0], bases[1])
|
||||||
ans = fromBaseTenTo(n, bases[1])
|
ans = fromBaseTenTo(n, bases[1])
|
||||||
return problem, ans
|
return problem, ans
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return fromBaseTenTo(n, bases[0]), bases[0], bases[1], fromBaseTenTo(
|
return fromBaseTenTo(n, bases[0]), bases[0], bases[1], fromBaseTenTo(
|
||||||
n, bases[1])
|
n, bases[1])
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ def binomialDistFunc(format='string'):
|
|||||||
"batch of {1:} pistons will contain no more than {2:} " \
|
"batch of {1:} pistons will contain no more than {2:} " \
|
||||||
"rejected pistons?".format(rejected_fraction, batch, rejections)
|
"rejected pistons?".format(rejected_fraction, batch, rejections)
|
||||||
return problem, answer
|
return problem, answer
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return rejected_fraction, batch, rejections, answer
|
return rejected_fraction, batch, rejections, answer
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def celsiustofahrenheitFunc(maxTemp=100, format='string'):
|
|||||||
celsius) + " degrees Celsius to degrees Fahrenheit ="
|
celsius) + " degrees Celsius to degrees Fahrenheit ="
|
||||||
solution = str(fahrenheit)
|
solution = str(fahrenheit)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return celsius, fahrenheit
|
return celsius, fahrenheit
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ def commonFactorsFunc(maxVal=100, format='string'):
|
|||||||
problem = f"Common Factors of {a} and {b} = "
|
problem = f"Common Factors of {a} and {b} = "
|
||||||
solution = arr
|
solution = arr
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, arr
|
return a, b, arr
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ def complexToPolarFunc(minRealImaginaryNum=-20,
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f'{r}({a}theta + i{b}theta)'
|
problem = f'{r}({a}theta + i{b}theta)'
|
||||||
return problem, theta
|
return problem, theta
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return r, a, b, theta
|
return r, a, b, theta
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = "The number " + str(x) + " in Roman Numerals is: "
|
problem = "The number " + str(x) + " in Roman Numerals is: "
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return x, solution
|
return x, solution
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def euclidianNormFunc(maxEltAmt=20, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"Euclidian norm or L2 norm of the vector{vec} is:"
|
problem = f"Euclidian norm or L2 norm of the vector{vec} is:"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return vec, solution
|
return vec, solution
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def gcdFunc(maxVal=20, format='string'):
|
|||||||
problem = f"GCD of {a} and {b} = "
|
problem = f"GCD of {a} and {b} = "
|
||||||
solution = str(x)
|
solution = str(x)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, x
|
return a, b, x
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ def geomProgrFunc(number_values=6,
|
|||||||
solution = "The value of a is {}, common ratio is {} , {}th term is {} , sum upto {}th term is {}".format(
|
solution = "The value of a is {}, common ratio is {} , {}th term is {} , sum upto {}th term is {}".format(
|
||||||
a, r, n_term, value_nth_term, sum_term, sum_till_nth_term)
|
a, r, n_term, value_nth_term, sum_term, sum_till_nth_term)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return GP, n_term, sum_term, a, r, n_term, value_nth_term, sum_term, sum_till_nth_term
|
return GP, n_term, sum_term, a, r, n_term, value_nth_term, sum_term, sum_till_nth_term
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def hcfFunc(maxVal=20, format='string'):
|
|||||||
problem = f"HCF of {a} and {b} = "
|
problem = f"HCF of {a} and {b} = "
|
||||||
solution = str(x)
|
solution = str(x)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, x
|
return a, b, x
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ def IsLeapYear(minNumber=1900, maxNumber=2099, format='string'):
|
|||||||
else:
|
else:
|
||||||
solution = "is not a leap year"
|
solution = "is not a leap year"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return year, ans
|
return year, ans
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ def lcmFunc(maxVal=20, format='string'):
|
|||||||
problem = f"LCM of {a} and {b} ="
|
problem = f"LCM of {a} and {b} ="
|
||||||
solution = str(d)
|
solution = str(d)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, d
|
return a, b, d
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ def minutesToHoursFunc(maxMinutes=999, format='string'):
|
|||||||
problem = f"Convert {minutes} minutes to Hours & Minutes"
|
problem = f"Convert {minutes} minutes to Hours & Minutes"
|
||||||
solution = f"{ansHours} hours and {ansMinutes} minutes"
|
solution = f"{ansHours} hours and {ansMinutes} minutes"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return minutes, ansHours, ansMinutes
|
return minutes, ansHours, ansMinutes
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ def primeFactorsFunc(minVal=1, maxVal=200, format='string'):
|
|||||||
problem = f"Find prime factors of {a}"
|
problem = f"Find prime factors of {a}"
|
||||||
solution = f"{factors}"
|
solution = f"{factors}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, factors
|
return a, factors
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ def profitLossPercentFunc(maxCP=1000, maxSP=1000, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"{profitOrLoss} percent when CP = {cP} and SP = {sP} is: "
|
problem = f"{profitOrLoss} percent when CP = {cP} and SP = {sP} is: "
|
||||||
return problem, str(percent)
|
return problem, str(percent)
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return profitOrLoss, cP, sP, percent
|
return profitOrLoss, cP, sP, percent
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def quotientOfPowerSameBaseFunc(maxBase=50, maxPower=10, format='string'):
|
|||||||
problem = f"The Quotient of {base}^{power1} and {base}^{power2} = " \
|
problem = f"The Quotient of {base}^{power1} and {base}^{power2} = " \
|
||||||
f"{base}^({power1}-{power2}) = {base}^{step}"
|
f"{base}^({power1}-{power2}) = {base}^{step}"
|
||||||
return problem, str(solution)
|
return problem, str(solution)
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return base, power1, power2, step, solution
|
return base, power1, power2, step, solution
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def quotientOfPowerSamePowerFunc(maxBase=50, maxPower=10, format='string'):
|
|||||||
problem = f"The Quotient of {base1}^{power} and {base2}^{power} = " \
|
problem = f"The Quotient of {base1}^{power} and {base2}^{power} = " \
|
||||||
f"({base1}/{base2})^{power} = {step}^{power}"
|
f"({base1}/{base2})^{power} = {step}^{power}"
|
||||||
return problem, str(solution)
|
return problem, str(solution)
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return base1, base2, power, step, solution
|
return base1, base2, power, step, solution
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ def signumFunc(min=-999, max=999, format='string'):
|
|||||||
problem = "signum of " + str(a) + " is " + "="
|
problem = "signum of " + str(a) + " is " + "="
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b
|
return a, b
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ def surdsComparisonFunc(maxValue=100, maxRoot=10, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"Fill in the blanks {radicand1}^(1/{degree1}) _ {radicand2}^(1/{degree2})"
|
problem = f"Fill in the blanks {radicand1}^(1/{degree1}) _ {radicand2}^(1/{degree2})"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return radicand1, degree1, radicand2, degree2, solution
|
return radicand1, degree1, radicand2, degree2, solution
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ def combinationsFunc(maxlength=20, format='string'):
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = f"Number of combinations from {a} objects picked {b} at a time "
|
problem = f"Number of combinations from {a} objects picked {b} at a time "
|
||||||
return problem, str(solution)
|
return problem, str(solution)
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, solution
|
return a, b, solution
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ def conditionalProbFunc(format='string'):
|
|||||||
P_disease, true_positive, true_negative)
|
P_disease, true_positive, true_negative)
|
||||||
solution = str(answer) + "%"
|
solution = str(answer) + "%"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return P_disease, true_positive, true_negative, answer
|
return P_disease, true_positive, true_negative, answer
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ def confidenceIntervalFunc(format='string'):
|
|||||||
[x for x in lst], lst_per[j])
|
[x for x in lst], lst_per[j])
|
||||||
solution = f'({upper}, {lower})'
|
solution = f'({upper}, {lower})'
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return [x for x in lst], lst_per[j], upper, lower
|
return [x for x in lst], lst_per[j], upper, lower
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ def dataSummaryFunc(number_values=15, minval=5, maxval=50, format='string'):
|
|||||||
str(random_list)
|
str(random_list)
|
||||||
solution = f"The Mean is {mean} , Standard Deviation is {standardDeviation}, Variance is {variance}"
|
solution = f"The Mean is {mean} , Standard Deviation is {standardDeviation}, Variance is {variance}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return random_list, mean, standardDeviation, variance
|
return random_list, mean, standardDeviation, variance
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ def DiceSumProbFunc(maxDice=3, format='string'):
|
|||||||
problem = f"If {a} dice are rolled at the same time, the probability of getting a sum of {b} ="
|
problem = f"If {a} dice are rolled at the same time, the probability of getting a sum of {b} ="
|
||||||
solution = f"{count}/{6**a}"
|
solution = f"{count}/{6**a}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, count, 6**a
|
return a, b, count, 6**a
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ def meanMedianFunc(maxlen=10, format='string'):
|
|||||||
problem = f"Given the series of numbers {randomlist}. find the arithmatic mean and mdian of the series"
|
problem = f"Given the series of numbers {randomlist}. find the arithmatic mean and mdian of the series"
|
||||||
solution = f"Arithmetic mean of the series is {mean} and Arithmetic median of this series is {median}"
|
solution = f"Arithmetic mean of the series is {mean} and Arithmetic median of this series is {median}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return randomlist, mean, median
|
return randomlist, mean, median
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ def permutationFunc(maxlength=20, format='string'):
|
|||||||
problem = f"Number of Permutations from {a} objects picked {b} at a time = "
|
problem = f"Number of Permutations from {a} objects picked {b} at a time = "
|
||||||
solution = str(answer)
|
solution = str(answer)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
elif format == 'latex':
|
||||||
|
return "Latex unavailable"
|
||||||
else:
|
else:
|
||||||
return a, b, answer
|
return a, b, answer
|
||||||
|
|
||||||
|
|||||||
155
scripts/makeReadme.py
Normal file
155
scripts/makeReadme.py
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
from mathgenerator.mathgen import *
|
||||||
|
|
||||||
|
write_list = []
|
||||||
|
subjects = [
|
||||||
|
'algebra', 'basic_math', 'calculus', 'computer_science', 'geometry',
|
||||||
|
'misc', 'statistics'
|
||||||
|
]
|
||||||
|
wList = getGenList()
|
||||||
|
|
||||||
|
|
||||||
|
def array2markdown_table(string):
|
||||||
|
string = string.replace("[[", "<table><tr><td>")
|
||||||
|
string = string.replace("[", "<tr><td>")
|
||||||
|
string = string.replace(", ", "</td><td>")
|
||||||
|
string = string.replace("]]", "</td></tr></table>")
|
||||||
|
string = string.replace("]", "</td></tr>")
|
||||||
|
string = string.replace(" ", "")
|
||||||
|
string = string.replace("\n", "")
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
|
def write_table_of_contents():
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
tc_lines = [
|
||||||
|
'* [Installation](#installation)\n',
|
||||||
|
'* [Basic Usage](#basic-usage)\n',
|
||||||
|
' * [More Complicated Usage](#more-complicated-usage)\n'
|
||||||
|
'* [Documentation](#documentation)\n',
|
||||||
|
'* [List of Generators](#list-of-generators)\n',
|
||||||
|
]
|
||||||
|
for subject in subjects:
|
||||||
|
line = ' * [' + subject + '](#' + subject + ')\n'
|
||||||
|
tc_lines.append(line)
|
||||||
|
|
||||||
|
with open('../README.md', "r") as g:
|
||||||
|
lines = g.readlines()
|
||||||
|
|
||||||
|
upper_bound = lines.index('## Table of Contents\n')
|
||||||
|
upper_lines = lines[:upper_bound + 1]
|
||||||
|
lower_bound = lines.index('## Installation\n')
|
||||||
|
lower_lines = lines[lower_bound - 1:]
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
for upper_line in upper_lines:
|
||||||
|
lines.append(upper_line)
|
||||||
|
for tc_line in tc_lines:
|
||||||
|
lines.append(tc_line)
|
||||||
|
for lower_line in lower_lines:
|
||||||
|
lines.append(lower_line)
|
||||||
|
|
||||||
|
with open('../README.md', "w") as g:
|
||||||
|
g.writelines(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def gen_to_row_string(item):
|
||||||
|
myGen = item[2]
|
||||||
|
# NOTE: renamed 'sol' to 'solu' to make it look nicer
|
||||||
|
prob, solu = myGen()
|
||||||
|
prob = str(prob).rstrip("\n")
|
||||||
|
solu = str(solu).rstrip("\n")
|
||||||
|
# edge case for matrixMultiplication
|
||||||
|
if item[0] == 46:
|
||||||
|
prob, solu = myGen(maxVal=10, max_dim=4)
|
||||||
|
prob = str(prob).rstrip("\n")
|
||||||
|
solu = str(solu).rstrip("\n")
|
||||||
|
prob = array2markdown_table(prob)
|
||||||
|
solu = array2markdown_table(solu)
|
||||||
|
|
||||||
|
# NOTE: renamed 'def_name' to 'func_name' because it suits it more
|
||||||
|
func_name = item[3]
|
||||||
|
kwargs = ""
|
||||||
|
kwargs_list = myGen.kwargs
|
||||||
|
for kwarg in kwargs_list:
|
||||||
|
kwargs += '`' + kwarg + '` '
|
||||||
|
title = '[' + myGen.title + '](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/' + item[
|
||||||
|
4] + '/' + func_name + '.py)'
|
||||||
|
row = [myGen.id, title, prob, solu, func_name, kwargs]
|
||||||
|
# tableLine = "| " + str(row[0]) + " | " + str(row[1]) + " | " + str(
|
||||||
|
# row[2]) + " | " + str(row[3]) + " | " + str(row[4]) + " |\n"
|
||||||
|
tableLine = "| " + str(row[0]) + " | " + str(row[1]) + " | " + str(
|
||||||
|
row[2]) + " | " + str(row[3]) + " | " + str(row[4]) + " | " + str(
|
||||||
|
row[5]) + " |\n"
|
||||||
|
print('added', item[1], '-', func_name, 'to the README.md')
|
||||||
|
return tableLine
|
||||||
|
|
||||||
|
|
||||||
|
def make_table_header(name):
|
||||||
|
lines = [
|
||||||
|
'## ' + name + '\n',
|
||||||
|
'| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |\n',
|
||||||
|
'|------|-------|-----------------|------------------|---------------|--------|\n'
|
||||||
|
]
|
||||||
|
for line in lines:
|
||||||
|
write_list.append(line)
|
||||||
|
|
||||||
|
|
||||||
|
def write_subject_table(subject_name, full_gen_list):
|
||||||
|
subject_list = []
|
||||||
|
# Create list of generators in given subject
|
||||||
|
for gen in full_gen_list:
|
||||||
|
if gen[4] == subject_name:
|
||||||
|
subject_list.append(gen)
|
||||||
|
subject_list.sort()
|
||||||
|
|
||||||
|
# Create table header
|
||||||
|
make_table_header(subject_name)
|
||||||
|
|
||||||
|
# Add each item to write_list
|
||||||
|
for item in subject_list:
|
||||||
|
write_list.append(gen_to_row_string(item))
|
||||||
|
|
||||||
|
|
||||||
|
def update_next_id():
|
||||||
|
next_id = len(getGenList())
|
||||||
|
new_lines = ""
|
||||||
|
file = open('../CONTRIBUTING.md', 'r')
|
||||||
|
for line in file:
|
||||||
|
new_line = ""
|
||||||
|
if "<!--Start next id-->" in line:
|
||||||
|
new_line = f" * Use this id: <!--Start next id-->{next_id}<!--End next id-->. (This is updated automatically after a new generator is added)\n"
|
||||||
|
else:
|
||||||
|
new_line = line
|
||||||
|
new_lines += new_line
|
||||||
|
file.close()
|
||||||
|
write_file = open("../CONTRIBUTING.md", "w")
|
||||||
|
write_file.write(new_lines)
|
||||||
|
write_file.close()
|
||||||
|
print("CONTRIBUTING.md updated")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
write_table_of_contents()
|
||||||
|
for subject in subjects:
|
||||||
|
write_subject_table(subject, wList)
|
||||||
|
|
||||||
|
with open('../README.md', "r") as g:
|
||||||
|
lines = g.readlines()
|
||||||
|
|
||||||
|
line = lines.index('## List of Generators\n')
|
||||||
|
lines = lines[:line + 1]
|
||||||
|
|
||||||
|
for write_line in write_list:
|
||||||
|
lines.append(write_line)
|
||||||
|
|
||||||
|
with open('../README.md', "w") as g:
|
||||||
|
g.writelines(lines)
|
||||||
|
|
||||||
|
print("New README.md table generated")
|
||||||
|
|
||||||
|
update_next_id()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -22,8 +22,9 @@ def get_filepaths(directory):
|
|||||||
|
|
||||||
|
|
||||||
# Run the above function and store its results in a variable.
|
# Run the above function and store its results in a variable.
|
||||||
full_file_paths = get_filepaths("mathgenerator/funcs/statistics")
|
full_file_paths = get_filepaths("../mathgenerator/funcs/algebra")
|
||||||
full_file_paths.sort()
|
full_file_paths.sort()
|
||||||
# print(full_file_paths)
|
# print(full_file_paths)
|
||||||
for item in full_file_paths:
|
for item in full_file_paths:
|
||||||
|
if item[:2] != '__':
|
||||||
print("from ." + item + " import *")
|
print("from ." + item + " import *")
|
||||||
5
scripts/needsLatex.py
Normal file
5
scripts/needsLatex.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from mathgenerator import mathgen
|
||||||
|
|
||||||
|
for item in mathgen.getGenList():
|
||||||
|
if item[2](format='latex') == 'Latex unavailable':
|
||||||
|
print(item[0], item[1], item[4])
|
||||||
4
scripts/nextId.py
Normal file
4
scripts/nextId.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Use this file to determine which ID to use for the next generator that you add
|
||||||
|
from mathgenerator import mathgen
|
||||||
|
|
||||||
|
print(mathgen.getGenList()[-1][0]+1)
|
||||||
Reference in New Issue
Block a user