diff --git a/README.md b/README.md index 03f7cad..d4ec6ed 100644 --- a/README.md +++ b/README.md @@ -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]` -* 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. diff --git a/mathgenerator/funcs/algebra/combine_like_terms.py b/mathgenerator/funcs/algebra/combine_like_terms.py index bb93073..f31604f 100644 --- a/mathgenerator/funcs/algebra/combine_like_terms.py +++ b/mathgenerator/funcs/algebra/combine_like_terms.py @@ -18,6 +18,8 @@ def likeTermCombineFunc(maxCoef=10, maxExp=20, maxTerms=10, format='string'): solution = combineTerms(problem) if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/algebra/compound_interest.py b/mathgenerator/funcs/algebra/compound_interest.py index 4efd60f..c787c81 100644 --- a/mathgenerator/funcs/algebra/compound_interest.py +++ b/mathgenerator/funcs/algebra/compound_interest.py @@ -15,6 +15,8 @@ def compoundInterestFunc(maxPrinciple=10000, str(p) + " dollars, " + str(r) + \ "% rate of interest and for a time period of " + str(n) + " year is = " return problem, str(a) + elif format == 'latex': + return "Latex unavailable" else: return p, r, n, a diff --git a/mathgenerator/funcs/algebra/distance_two_points.py b/mathgenerator/funcs/algebra/distance_two_points.py index 3f26c75..a0f5cb6 100644 --- a/mathgenerator/funcs/algebra/distance_two_points.py +++ b/mathgenerator/funcs/algebra/distance_two_points.py @@ -13,6 +13,8 @@ def distanceTwoPointsFunc(maxValXY=20, minValXY=-20, format='string'): solution = f"sqrt({distanceSq})" problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return point1X, point1Y, point2X, point2Y, distanceSq diff --git a/mathgenerator/funcs/algebra/expanding.py b/mathgenerator/funcs/algebra/expanding.py index 2301d27..e4bd8ca 100644 --- a/mathgenerator/funcs/algebra/expanding.py +++ b/mathgenerator/funcs/algebra/expanding.py @@ -48,6 +48,8 @@ def expandingFunc(range_x1=10, problem = f"({p1}x{p2})({p3}x{p4})" solution = f"{c1}*x^2{c2}*x{c3}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return p1, p2, p3, p4, c1, c2, c3 diff --git a/mathgenerator/funcs/algebra/factoring.py b/mathgenerator/funcs/algebra/factoring.py index b24368a..1191aff 100644 --- a/mathgenerator/funcs/algebra/factoring.py +++ b/mathgenerator/funcs/algebra/factoring.py @@ -28,6 +28,8 @@ def factoringFunc(range_x1=10, range_x2=10, format='string'): x2 = intParser(x2) solution = f"(x{x1})(x{x2})" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return b, c, x1, x2 diff --git a/mathgenerator/funcs/algebra/int_matrix_22_determinant.py b/mathgenerator/funcs/algebra/int_matrix_22_determinant.py index 7c77ae4..46186fb 100644 --- a/mathgenerator/funcs/algebra/int_matrix_22_determinant.py +++ b/mathgenerator/funcs/algebra/int_matrix_22_determinant.py @@ -13,6 +13,8 @@ def determinantToMatrix22(maxMatrixVal=100, format='string'): problem = f"Det([[{a}, {b}], [{c}, {d}]]) = " solution = f" {determinant}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c, d, determinant diff --git a/mathgenerator/funcs/algebra/intersection_of_two_lines.py b/mathgenerator/funcs/algebra/intersection_of_two_lines.py index bc4b5a7..622b7be 100644 --- a/mathgenerator/funcs/algebra/intersection_of_two_lines.py +++ b/mathgenerator/funcs/algebra/intersection_of_two_lines.py @@ -68,6 +68,8 @@ def intersectionOfTwoLinesFunc(minM=-10, if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return equation1, equation2, solution diff --git a/mathgenerator/funcs/algebra/invert_matrix.py b/mathgenerator/funcs/algebra/invert_matrix.py index 6879b89..a3775f3 100644 --- a/mathgenerator/funcs/algebra/invert_matrix.py +++ b/mathgenerator/funcs/algebra/invert_matrix.py @@ -79,6 +79,8 @@ def matrixInversion(SquareMatrixDimension=3, problem = 'Inverse of Matrix ' + str(Mat) + ' is:' solution = str(sympy.Matrix.inv(Mat)) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return Mat, sympy.Matrix.inv(Mat) diff --git a/mathgenerator/funcs/algebra/linear_equations.py b/mathgenerator/funcs/algebra/linear_equations.py index 998a8cf..f061b21 100644 --- a/mathgenerator/funcs/algebra/linear_equations.py +++ b/mathgenerator/funcs/algebra/linear_equations.py @@ -30,6 +30,8 @@ def linearEquationsFunc(n=2, varRange=20, coeffRange=20, format='string'): if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/algebra/log.py b/mathgenerator/funcs/algebra/log.py index 4960382..24f5fec 100644 --- a/mathgenerator/funcs/algebra/log.py +++ b/mathgenerator/funcs/algebra/log.py @@ -12,7 +12,6 @@ def logFunc(maxBase=3, maxVal=8, format='string'): return problem, solution elif format == 'latex': problem = "\\(\\log_{" + str(b) + "}" + str(c) + "\\)" - print(problem) solution = "\\(" + str(a) + "\\)" return problem, solution else: diff --git a/mathgenerator/funcs/algebra/matrix_multiplication.py b/mathgenerator/funcs/algebra/matrix_multiplication.py index 2b24303..c78db9d 100644 --- a/mathgenerator/funcs/algebra/matrix_multiplication.py +++ b/mathgenerator/funcs/algebra/matrix_multiplication.py @@ -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}" solution = matrixMultiplicationFuncHelper(res) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a_string, b_string, res diff --git a/mathgenerator/funcs/algebra/midpoint_of_two_points.py b/mathgenerator/funcs/algebra/midpoint_of_two_points.py index 1191cf4..6743af5 100644 --- a/mathgenerator/funcs/algebra/midpoint_of_two_points.py +++ b/mathgenerator/funcs/algebra/midpoint_of_two_points.py @@ -13,6 +13,8 @@ def MidPointOfTwoPointFunc(maxValue=20, format='string'): problem = f"({x1},{y1}),({x2},{y2})=" solution = f"({xm},{ym})" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return x1, y1, x2, y2, xm, ym diff --git a/mathgenerator/funcs/algebra/multiply_complex_numbers.py b/mathgenerator/funcs/algebra/multiply_complex_numbers.py index e98622a..f5fc994 100644 --- a/mathgenerator/funcs/algebra/multiply_complex_numbers.py +++ b/mathgenerator/funcs/algebra/multiply_complex_numbers.py @@ -9,10 +9,13 @@ def multiplyComplexNumbersFunc(minRealImaginaryNum=-20, num2 = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum), random.randint(minRealImaginaryNum, maxRealImaginaryNum)) product = num1 * num2 + if format == 'string': problem = f"{num1} * {num2} = " solution = str(product) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return num1, num2, product diff --git a/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py b/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py index 4e8efec..69e5c33 100644 --- a/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py +++ b/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py @@ -18,7 +18,7 @@ def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100, format='string'): problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = " solution = f"[[{a1},{b1}],[{c1},{d1}]]" return problem, solution - elif style == 'latex': + elif format == 'latex': problem = "\\(" + str(constant) + "\\cdot\\begin{bmatrix}" + str( a) + "&" + str(b) + "\\\\" + str(c) + "&" + str( d) + "\\end{bmatrix}=\\)" diff --git a/mathgenerator/funcs/algebra/quadratic_equation.py b/mathgenerator/funcs/algebra/quadratic_equation.py index 6c26771..77d5d6e 100644 --- a/mathgenerator/funcs/algebra/quadratic_equation.py +++ b/mathgenerator/funcs/algebra/quadratic_equation.py @@ -16,6 +16,8 @@ def quadraticEquation(maxVal=100, format='string'): a, b, c) solution = str(res) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c, res diff --git a/mathgenerator/funcs/algebra/simple_interest.py b/mathgenerator/funcs/algebra/simple_interest.py index ffa9ab9..fe54296 100644 --- a/mathgenerator/funcs/algebra/simple_interest.py +++ b/mathgenerator/funcs/algebra/simple_interest.py @@ -17,6 +17,8 @@ def simpleInterestFunc(maxPrinciple=10000, c) + " years is = " solution = str(d) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c, d diff --git a/mathgenerator/funcs/algebra/system_of_equations.py b/mathgenerator/funcs/algebra/system_of_equations.py index c3a78aa..c93a79e 100644 --- a/mathgenerator/funcs/algebra/system_of_equations.py +++ b/mathgenerator/funcs/algebra/system_of_equations.py @@ -48,6 +48,8 @@ def systemOfEquationsFunc(range_x=10, problem = f"{coeffToFuncString(new_c1)}, {coeffToFuncString(new_c2)}" solution = f"x = {x}, y = {y}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return new_c1, new_c2, x, y # Add random (non-zero) multiple of equations to each other diff --git a/mathgenerator/funcs/algebra/vector_cross.py b/mathgenerator/funcs/algebra/vector_cross.py index a428060..496ca82 100644 --- a/mathgenerator/funcs/algebra/vector_cross.py +++ b/mathgenerator/funcs/algebra/vector_cross.py @@ -13,6 +13,8 @@ def vectorCrossFunc(minVal=-20, maxVal=20, format='string'): problem = str(a) + " X " + str(b) + " = " solution = str(c) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c diff --git a/mathgenerator/funcs/algebra/vector_dot.py b/mathgenerator/funcs/algebra/vector_dot.py index 4d3180c..1013ecd 100644 --- a/mathgenerator/funcs/algebra/vector_dot.py +++ b/mathgenerator/funcs/algebra/vector_dot.py @@ -10,6 +10,8 @@ def vectorDotFunc(minVal=-20, maxVal=20, format='string'): problem = str(a) + " . " + str(b) + " = " solution = str(c) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c diff --git a/mathgenerator/funcs/basic_math/factorial.py b/mathgenerator/funcs/basic_math/factorial.py index 8bf8540..500d8fc 100644 --- a/mathgenerator/funcs/basic_math/factorial.py +++ b/mathgenerator/funcs/basic_math/factorial.py @@ -11,6 +11,8 @@ def factorialFunc(maxInput=6, format='string'): if format == 'string': return str(a) + "! = ", str(b) + elif format == 'latex': + return "Latex unavailable" else: return a, b diff --git a/mathgenerator/funcs/basic_math/is_prime.py b/mathgenerator/funcs/basic_math/is_prime.py index b13d648..eb0746e 100644 --- a/mathgenerator/funcs/basic_math/is_prime.py +++ b/mathgenerator/funcs/basic_math/is_prime.py @@ -18,6 +18,8 @@ def isprime(max_num=100, format='string'): if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, solution diff --git a/mathgenerator/funcs/basic_math/percentage.py b/mathgenerator/funcs/basic_math/percentage.py index b9ec0e4..fae3f19 100644 --- a/mathgenerator/funcs/basic_math/percentage.py +++ b/mathgenerator/funcs/basic_math/percentage.py @@ -11,6 +11,8 @@ def percentageFunc(maxValue=99, maxpercentage=99, format='string'): if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, formatted_float diff --git a/mathgenerator/funcs/basic_math/subtraction.py b/mathgenerator/funcs/basic_math/subtraction.py index 1368265..6a1c8f5 100644 --- a/mathgenerator/funcs/basic_math/subtraction.py +++ b/mathgenerator/funcs/basic_math/subtraction.py @@ -10,6 +10,8 @@ def subtractionFunc(maxMinuend=99, maxDiff=99, format='string'): problem = str(a) + "-" + str(b) + "=" solution = str(c) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c diff --git a/mathgenerator/funcs/calculus/definite_integral.py b/mathgenerator/funcs/calculus/definite_integral.py index cb50bad..3b3c32e 100644 --- a/mathgenerator/funcs/calculus/definite_integral.py +++ b/mathgenerator/funcs/calculus/definite_integral.py @@ -19,6 +19,8 @@ def definiteIntegralFunc(max_coeff=100, format='string'): str(a) + "x^2 + " + str(b) + "x + " + str(c) + " is = " solution = str(S) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c, S diff --git a/mathgenerator/funcs/calculus/differentiation.py b/mathgenerator/funcs/calculus/differentiation.py index 87f9f61..b814266 100644 --- a/mathgenerator/funcs/calculus/differentiation.py +++ b/mathgenerator/funcs/calculus/differentiation.py @@ -47,6 +47,8 @@ def differentiationFunc(diff_lvl=2, format='string'): if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/calculus/power_rule_differentiation.py b/mathgenerator/funcs/calculus/power_rule_differentiation.py index 7259a54..df9decc 100644 --- a/mathgenerator/funcs/calculus/power_rule_differentiation.py +++ b/mathgenerator/funcs/calculus/power_rule_differentiation.py @@ -21,6 +21,8 @@ def powerRuleDifferentiationFunc(maxCoef=10, if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/calculus/power_rule_integration.py b/mathgenerator/funcs/calculus/power_rule_integration.py index 234ad7c..23e07d7 100644 --- a/mathgenerator/funcs/calculus/power_rule_integration.py +++ b/mathgenerator/funcs/calculus/power_rule_integration.py @@ -24,6 +24,8 @@ def powerRuleIntegrationFunc(maxCoef=10, if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/calculus/stationary_points.py b/mathgenerator/funcs/calculus/stationary_points.py index 1132e82..ef43951 100644 --- a/mathgenerator/funcs/calculus/stationary_points.py +++ b/mathgenerator/funcs/calculus/stationary_points.py @@ -18,6 +18,8 @@ def stationaryPointsFunc(maxExp=3, maxCoef=10, format='string'): problem = 'f(x)=' + str(problem).replace('**', '^') if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/computer_science/bcd_to_decimal.py b/mathgenerator/funcs/computer_science/bcd_to_decimal.py index 09a8aa9..84d908c 100644 --- a/mathgenerator/funcs/computer_science/bcd_to_decimal.py +++ b/mathgenerator/funcs/computer_science/bcd_to_decimal.py @@ -19,6 +19,8 @@ def BCDtoDecimalFunc(maxNumber=10000, format='string'): problem = "Integer of Binary Coded Decimal " + str(n) + " is = " solution = int(binstring, 2) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return n, int(binstring, 2) diff --git a/mathgenerator/funcs/computer_science/binary_2s_complement.py b/mathgenerator/funcs/computer_science/binary_2s_complement.py index b8202ed..4b8c1d3 100644 --- a/mathgenerator/funcs/computer_science/binary_2s_complement.py +++ b/mathgenerator/funcs/computer_science/binary_2s_complement.py @@ -27,6 +27,8 @@ def binary2sComplementFunc(maxDigits=10, format='string'): problem = "2's complement of " + question + " =" solution = ''.join(answer).lstrip('0') return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return question, answer diff --git a/mathgenerator/funcs/computer_science/binary_complement_1s.py b/mathgenerator/funcs/computer_science/binary_complement_1s.py index 0e39d7c..7a314b1 100644 --- a/mathgenerator/funcs/computer_science/binary_complement_1s.py +++ b/mathgenerator/funcs/computer_science/binary_complement_1s.py @@ -13,6 +13,8 @@ def binaryComplement1sFunc(maxDigits=10, format='string'): if format == 'string': problem = question + "=" return problem, answer + elif format == 'latex': + return "Latex unavailable" else: return problem, answer diff --git a/mathgenerator/funcs/computer_science/binary_to_decimal.py b/mathgenerator/funcs/computer_science/binary_to_decimal.py index 81e9873..9d1367f 100644 --- a/mathgenerator/funcs/computer_science/binary_to_decimal.py +++ b/mathgenerator/funcs/computer_science/binary_to_decimal.py @@ -11,6 +11,8 @@ def binaryToDecimalFunc(max_dig=10, format='string'): if format == 'string': solution = int(problem, 2) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/computer_science/binary_to_hex.py b/mathgenerator/funcs/computer_science/binary_to_hex.py index 0841596..fb76ecf 100644 --- a/mathgenerator/funcs/computer_science/binary_to_hex.py +++ b/mathgenerator/funcs/computer_science/binary_to_hex.py @@ -10,6 +10,8 @@ def binaryToHexFunc(max_dig=10, format='string'): if format == 'string': solution = hex(int(problem, 2)) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return problem, solution diff --git a/mathgenerator/funcs/computer_science/decimal_to_bcd.py b/mathgenerator/funcs/computer_science/decimal_to_bcd.py index 52a273f..0774ef9 100644 --- a/mathgenerator/funcs/computer_science/decimal_to_bcd.py +++ b/mathgenerator/funcs/computer_science/decimal_to_bcd.py @@ -11,9 +11,14 @@ def DecimalToBCDFunc(maxNumber=10000, format='string'): bcdstring = str(nibble) + bcdstring x >>= 4 - problem = "BCD of Decimal Number " + str(n) + " is = " - solution = int(bcdstring) - return problem, solution + if format == 'string': + problem = "BCD of Decimal Number " + str(n) + " is = " + solution = bcdstring + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return n, int(bcdstring) decimal_to_bcd = Generator("Decimal to Binary Coded Decimal", 103, diff --git a/mathgenerator/funcs/computer_science/decimal_to_binary.py b/mathgenerator/funcs/computer_science/decimal_to_binary.py index f47ce75..133afe3 100644 --- a/mathgenerator/funcs/computer_science/decimal_to_binary.py +++ b/mathgenerator/funcs/computer_science/decimal_to_binary.py @@ -5,11 +5,14 @@ def DecimalToBinaryFunc(max_dec=99, format='string'): a = random.randint(1, max_dec) b = bin(a).replace("0b", "") - problem = "Binary of " + str(a) + "=" - solution = str(b) - - return problem, solution - + if format == 'string': + problem = "Binary of " + str(a) + "=" + solution = str(b) + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return a, str(b) decimal_to_binary = Generator("Decimal to Binary", 14, DecimalToBinaryFunc, ["max_dec=99"]) diff --git a/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py b/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py index dbc69aa..6467806 100644 --- a/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py +++ b/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py @@ -4,10 +4,15 @@ from .__init__ import * def deciToHexaFunc(max_dec=1000, format='string'): a = random.randint(0, max_dec) b = hex(a) - problem = "Binary of " + str(a) + "=" - solution = str(b) - return problem, solution + if format == 'string': + problem = "Binary of " + str(a) + "=" + solution = str(b) + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return a, str(b) decimal_to_hexadeci = Generator("Decimal to Hexadecimal", 79, deciToHexaFunc, diff --git a/mathgenerator/funcs/computer_science/decimal_to_octal.py b/mathgenerator/funcs/computer_science/decimal_to_octal.py index fc1b5f9..6e61565 100644 --- a/mathgenerator/funcs/computer_science/decimal_to_octal.py +++ b/mathgenerator/funcs/computer_science/decimal_to_octal.py @@ -8,6 +8,8 @@ def decimalToOctalFunc(maxDecimal=4096, format='string'): if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return x, oct(x) diff --git a/mathgenerator/funcs/computer_science/fibonacci_series.py b/mathgenerator/funcs/computer_science/fibonacci_series.py index 93a84e3..8ac40dc 100644 --- a/mathgenerator/funcs/computer_science/fibonacci_series.py +++ b/mathgenerator/funcs/computer_science/fibonacci_series.py @@ -20,6 +20,8 @@ def fibonacciSeriesFunc(minNo=1, format='string'): problem = "The Fibonacci Series of the first " + str( n) + " numbers is ?" return problem, fibList + elif format == 'latex': + return "Latex unavailable" else: return n, fibList diff --git a/mathgenerator/funcs/computer_science/modulo_division.py b/mathgenerator/funcs/computer_science/modulo_division.py index a25837a..944b0fc 100644 --- a/mathgenerator/funcs/computer_science/modulo_division.py +++ b/mathgenerator/funcs/computer_science/modulo_division.py @@ -10,6 +10,8 @@ def moduloFunc(maxRes=99, maxModulo=99, format='string'): problem = str(a) + "%" + str(b) + "=" solution = str(c) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c diff --git a/mathgenerator/funcs/computer_science/nth_fibonacci_number.py b/mathgenerator/funcs/computer_science/nth_fibonacci_number.py index a123a5d..f11f3ff 100644 --- a/mathgenerator/funcs/computer_science/nth_fibonacci_number.py +++ b/mathgenerator/funcs/computer_science/nth_fibonacci_number.py @@ -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))) if format == 'string': - solution = f"{ans}" - return problem, solution + return problem, str(ans) + elif format == 'latex': + return "Latex unavailable" else: return n, ans diff --git a/mathgenerator/funcs/geometry/angle_btw_vectors.py b/mathgenerator/funcs/geometry/angle_btw_vectors.py index aade7ed..7175ea7 100644 --- a/mathgenerator/funcs/geometry/angle_btw_vectors.py +++ b/mathgenerator/funcs/geometry/angle_btw_vectors.py @@ -14,15 +14,23 @@ def angleBtwVectorsFunc(maxEltAmt=20, format='string'): mags = math.sqrt(sum([i**2 for i in v1])) * math.sqrt(sum([i**2 for i in v2])) - problem = f"angle between the vectors {v1} and {v2} is:" solution = '' + ans = 0 try: - solution = str(round(math.acos(s / mags), 2)) + " radians" + ans = round(math.acos(s / mags), 2) + solution = str(ans) + " radians" except ValueError: print('angleBtwVectorsFunc has some issues with math module, line 16') solution = 'NaN' + ans = 'NaN' # would return the answer in radians - return problem, solution + if format == 'string': + problem = f"angle between the vectors {v1} and {v2} is:" + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return v1, v2, ans angle_btw_vectors = Generator("Angle between 2 vectors", 70, diff --git a/mathgenerator/funcs/geometry/angle_regular_polygon.py b/mathgenerator/funcs/geometry/angle_regular_polygon.py index b0ce535..ed8fd21 100644 --- a/mathgenerator/funcs/geometry/angle_regular_polygon.py +++ b/mathgenerator/funcs/geometry/angle_regular_polygon.py @@ -10,6 +10,8 @@ def regularPolygonAngleFunc(minVal=3, maxVal=20, format='string'): if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return sideNum, solution diff --git a/mathgenerator/funcs/geometry/arc_length.py b/mathgenerator/funcs/geometry/arc_length.py index 12992e7..e60b7b6 100644 --- a/mathgenerator/funcs/geometry/arc_length.py +++ b/mathgenerator/funcs/geometry/arc_length.py @@ -13,6 +13,8 @@ def arclengthFunc(maxRadius=49, maxAngle=359, format='string'): if format == 'string': solution = f"Arc length of the angle = {formatted_float}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return radius, angle, formatted_float diff --git a/mathgenerator/funcs/geometry/area_of_circle.py b/mathgenerator/funcs/geometry/area_of_circle.py index b3b5b54..b7f830e 100644 --- a/mathgenerator/funcs/geometry/area_of_circle.py +++ b/mathgenerator/funcs/geometry/area_of_circle.py @@ -9,6 +9,8 @@ def areaCircle(maxRadius=100, format='string'): if format == 'string': problem = f"Area of circle with radius {r}" return problem, str(area) + elif format == 'latex': + return "Latex unavailable" else: return r, area diff --git a/mathgenerator/funcs/geometry/area_of_triangle.py b/mathgenerator/funcs/geometry/area_of_triangle.py index b223104..68abb5a 100644 --- a/mathgenerator/funcs/geometry/area_of_triangle.py +++ b/mathgenerator/funcs/geometry/area_of_triangle.py @@ -14,6 +14,8 @@ def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20, format='string'): str(a) + " " + str(b) + " " + str(c) + " = " solution = str(area) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c, area diff --git a/mathgenerator/funcs/geometry/basic_trigonometry.py b/mathgenerator/funcs/geometry/basic_trigonometry.py index ae9b0a5..e2bcfb8 100644 --- a/mathgenerator/funcs/geometry/basic_trigonometry.py +++ b/mathgenerator/funcs/geometry/basic_trigonometry.py @@ -28,6 +28,8 @@ def basicTrigonometryFunc(angles=[0, 30, 45, 60, 90], if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return function, angle, solution diff --git a/mathgenerator/funcs/geometry/circumference.py b/mathgenerator/funcs/geometry/circumference.py index 60fc308..446a127 100644 --- a/mathgenerator/funcs/geometry/circumference.py +++ b/mathgenerator/funcs/geometry/circumference.py @@ -9,6 +9,8 @@ def circumferenceCircle(maxRadius=100, format='string'): if format == 'string': problem = f"Circumference of circle with radius {r}" return problem, circumference + elif format == 'latex': + return "Latex unavailable" else: return r, circumference diff --git a/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py b/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py index 7d8375c..7e41dc2 100644 --- a/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py +++ b/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py @@ -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}?" solution = f"CSA of cylinder = {formatted_float}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return r, h, formatted_float diff --git a/mathgenerator/funcs/geometry/degree_to_rad.py b/mathgenerator/funcs/geometry/degree_to_rad.py index 72c8d1c..d7159bc 100644 --- a/mathgenerator/funcs/geometry/degree_to_rad.py +++ b/mathgenerator/funcs/geometry/degree_to_rad.py @@ -11,6 +11,8 @@ def degreeToRadFunc(max_deg=360, format='string'): problem = "Angle " + str(a) + " in radians is = " solution = str(b) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b diff --git a/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py b/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py index 27a7677..76a7001 100644 --- a/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py +++ b/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py @@ -13,6 +13,8 @@ def fourthAngleOfQuadriFunc(maxAngle=180, format='string'): problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} =" solution = angle4 return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return angle1, angle2, angle3, angle4 diff --git a/mathgenerator/funcs/geometry/perimeter_of_polygons.py b/mathgenerator/funcs/geometry/perimeter_of_polygons.py index 72948ac..cae88e5 100644 --- a/mathgenerator/funcs/geometry/perimeter_of_polygons.py +++ b/mathgenerator/funcs/geometry/perimeter_of_polygons.py @@ -14,6 +14,8 @@ def perimeterOfPolygons(maxSides=12, maxLength=120, format='string'): if format == 'string': return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return size_of_sides, sides, solution diff --git a/mathgenerator/funcs/geometry/pythagorean_theorem.py b/mathgenerator/funcs/geometry/pythagorean_theorem.py index 5021aa3..cfb441f 100644 --- a/mathgenerator/funcs/geometry/pythagorean_theorem.py +++ b/mathgenerator/funcs/geometry/pythagorean_theorem.py @@ -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} = " solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, round(c, 2) diff --git a/mathgenerator/funcs/geometry/radian_to_deg.py b/mathgenerator/funcs/geometry/radian_to_deg.py index fa9f133..932ed97 100644 --- a/mathgenerator/funcs/geometry/radian_to_deg.py +++ b/mathgenerator/funcs/geometry/radian_to_deg.py @@ -12,6 +12,8 @@ def radianToDegFunc(max_rad=3, format='string'): problem = "Angle " + str(a) + " in degrees is = " solution = str(b) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b diff --git a/mathgenerator/funcs/geometry/sector_area.py b/mathgenerator/funcs/geometry/sector_area.py index d09c1e7..06b004c 100644 --- a/mathgenerator/funcs/geometry/sector_area.py +++ b/mathgenerator/funcs/geometry/sector_area.py @@ -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." solution = f"Area of sector = {formatted_float}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return r, a, formatted_float diff --git a/mathgenerator/funcs/geometry/sum_of_polygon_angles.py b/mathgenerator/funcs/geometry/sum_of_polygon_angles.py index 3bf4c71..2b4e542 100644 --- a/mathgenerator/funcs/geometry/sum_of_polygon_angles.py +++ b/mathgenerator/funcs/geometry/sum_of_polygon_angles.py @@ -8,6 +8,8 @@ def sumOfAnglesOfPolygonFunc(maxSides=12, format='string'): if format == 'string': problem = f"Sum of angles of polygon with {side_count} sides = " return problem, sum + elif format == 'latex': + return "Latex unavailable" else: return side_count, sum diff --git a/mathgenerator/funcs/geometry/surface_area_cone.py b/mathgenerator/funcs/geometry/surface_area_cone.py index 0efb53f..7567332 100644 --- a/mathgenerator/funcs/geometry/surface_area_cone.py +++ b/mathgenerator/funcs/geometry/surface_area_cone.py @@ -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" solution = f"{ans} {unit}^2" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, ans, unit diff --git a/mathgenerator/funcs/geometry/surface_area_cube.py b/mathgenerator/funcs/geometry/surface_area_cube.py index 6306439..cbd67d7 100644 --- a/mathgenerator/funcs/geometry/surface_area_cube.py +++ b/mathgenerator/funcs/geometry/surface_area_cube.py @@ -9,6 +9,8 @@ def surfaceAreaCube(maxSide=20, unit='m', format='string'): problem = f"Surface area of cube with side = {a}{unit} is" solution = f"{ans} {unit}^2" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, ans, unit diff --git a/mathgenerator/funcs/geometry/surface_area_cuboid.py b/mathgenerator/funcs/geometry/surface_area_cuboid.py index c6c3108..df9af8c 100644 --- a/mathgenerator/funcs/geometry/surface_area_cuboid.py +++ b/mathgenerator/funcs/geometry/surface_area_cuboid.py @@ -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" solution = f"{ans} {unit}^2" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c, ans, unit diff --git a/mathgenerator/funcs/geometry/surface_area_cylinder.py b/mathgenerator/funcs/geometry/surface_area_cylinder.py index 63a3dcb..5e37216 100644 --- a/mathgenerator/funcs/geometry/surface_area_cylinder.py +++ b/mathgenerator/funcs/geometry/surface_area_cylinder.py @@ -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" solution = f"{ans} {unit}^2" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, ans, unit diff --git a/mathgenerator/funcs/geometry/surface_area_sphere.py b/mathgenerator/funcs/geometry/surface_area_sphere.py index 51828e2..6f6aa31 100644 --- a/mathgenerator/funcs/geometry/surface_area_sphere.py +++ b/mathgenerator/funcs/geometry/surface_area_sphere.py @@ -9,6 +9,8 @@ def surfaceAreaSphere(maxSide=20, unit='m', format='string'): problem = f"Surface area of Sphere with radius = {r}{unit} is" solution = f"{ans} {unit}^2" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return r, ans, unit diff --git a/mathgenerator/funcs/geometry/third_angle_of_triangle.py b/mathgenerator/funcs/geometry/third_angle_of_triangle.py index 4aeb6c4..46fffa8 100644 --- a/mathgenerator/funcs/geometry/third_angle_of_triangle.py +++ b/mathgenerator/funcs/geometry/third_angle_of_triangle.py @@ -9,6 +9,8 @@ def thirdAngleOfTriangleFunc(maxAngle=89, format='string'): if format == 'string': problem = f"Third angle of triangle with angles {angle1} and {angle2} = " return problem, angle3 + elif format == 'latex': + return "Latex unavailable" else: return angle1, angle2, angle3 diff --git a/mathgenerator/funcs/geometry/valid_triangle.py b/mathgenerator/funcs/geometry/valid_triangle.py index 145edc1..6f64f4e 100644 --- a/mathgenerator/funcs/geometry/valid_triangle.py +++ b/mathgenerator/funcs/geometry/valid_triangle.py @@ -19,6 +19,8 @@ def isTriangleValidFunc(maxSideLength=50, format='string'): else: solution = "No" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return sideA, sideB, sideC, exists diff --git a/mathgenerator/funcs/geometry/volume_cone.py b/mathgenerator/funcs/geometry/volume_cone.py index de50796..e5f915b 100644 --- a/mathgenerator/funcs/geometry/volume_cone.py +++ b/mathgenerator/funcs/geometry/volume_cone.py @@ -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" solution = f"{ans} {unit}^3" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, ans, unit diff --git a/mathgenerator/funcs/geometry/volume_cube.py b/mathgenerator/funcs/geometry/volume_cube.py index 69ce7d3..62d190d 100644 --- a/mathgenerator/funcs/geometry/volume_cube.py +++ b/mathgenerator/funcs/geometry/volume_cube.py @@ -9,6 +9,8 @@ def volumeCube(maxSide=20, unit='m', format='string'): problem = f"Volume of cube with side = {a}{unit} is" solution = f"{ans} {unit}^3" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, ans, unit diff --git a/mathgenerator/funcs/geometry/volume_cuboid.py b/mathgenerator/funcs/geometry/volume_cuboid.py index 3f17efc..ca0076c 100644 --- a/mathgenerator/funcs/geometry/volume_cuboid.py +++ b/mathgenerator/funcs/geometry/volume_cuboid.py @@ -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" solution = f"{ans} {unit}^3" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, c, ans, unit diff --git a/mathgenerator/funcs/geometry/volume_cylinder.py b/mathgenerator/funcs/geometry/volume_cylinder.py index e08a688..230c87a 100644 --- a/mathgenerator/funcs/geometry/volume_cylinder.py +++ b/mathgenerator/funcs/geometry/volume_cylinder.py @@ -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" solution = f"{ans} {unit}^3" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, ans, unit diff --git a/mathgenerator/funcs/geometry/volume_sphere.py b/mathgenerator/funcs/geometry/volume_sphere.py index ed922b1..ef0b559 100644 --- a/mathgenerator/funcs/geometry/volume_sphere.py +++ b/mathgenerator/funcs/geometry/volume_sphere.py @@ -9,6 +9,8 @@ def volumeSphereFunc(maxRadius=100, format='string'): problem = f"Volume of sphere with radius {r} m = " solution = f"{ans} m^3" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return r, ans diff --git a/mathgenerator/funcs/misc/arithmetic_progression_sum.py b/mathgenerator/funcs/misc/arithmetic_progression_sum.py index c32b915..f347161 100644 --- a/mathgenerator/funcs/misc/arithmetic_progression_sum.py +++ b/mathgenerator/funcs/misc/arithmetic_progression_sum.py @@ -18,6 +18,8 @@ def arithmeticProgressionSumFunc(maxd=100, problem = 'Find the sum of first ' + \ str(n) + ' terms of the AP series: ' + apString return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return n, apString, solution diff --git a/mathgenerator/funcs/misc/arithmetic_progression_term.py b/mathgenerator/funcs/misc/arithmetic_progression_term.py index 1ad47a2..2e84a7d 100644 --- a/mathgenerator/funcs/misc/arithmetic_progression_term.py +++ b/mathgenerator/funcs/misc/arithmetic_progression_term.py @@ -17,6 +17,8 @@ def arithmeticProgressionTermFunc(maxd=100, problem = 'Find the term number ' + str( n) + ' of the AP series: ' + apString return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return n, apString, solution diff --git a/mathgenerator/funcs/misc/base_conversion.py b/mathgenerator/funcs/misc/base_conversion.py index 5ad2294..d9fd640 100644 --- a/mathgenerator/funcs/misc/base_conversion.py +++ b/mathgenerator/funcs/misc/base_conversion.py @@ -52,6 +52,8 @@ def baseConversionFunc(maxNum=60000, maxBase=16, format='string'): fromBaseTenTo(n, bases[0]), bases[0], bases[1]) ans = fromBaseTenTo(n, bases[1]) return problem, ans + elif format == 'latex': + return "Latex unavailable" else: return fromBaseTenTo(n, bases[0]), bases[0], bases[1], fromBaseTenTo( n, bases[1]) diff --git a/mathgenerator/funcs/misc/binomial_distribution.py b/mathgenerator/funcs/misc/binomial_distribution.py index a9573e4..37b812b 100644 --- a/mathgenerator/funcs/misc/binomial_distribution.py +++ b/mathgenerator/funcs/misc/binomial_distribution.py @@ -33,6 +33,8 @@ def binomialDistFunc(format='string'): "batch of {1:} pistons will contain no more than {2:} " \ "rejected pistons?".format(rejected_fraction, batch, rejections) return problem, answer + elif format == 'latex': + return "Latex unavailable" else: return rejected_fraction, batch, rejections, answer diff --git a/mathgenerator/funcs/misc/celsius_to_fahrenheit.py b/mathgenerator/funcs/misc/celsius_to_fahrenheit.py index f80ad6b..2846876 100644 --- a/mathgenerator/funcs/misc/celsius_to_fahrenheit.py +++ b/mathgenerator/funcs/misc/celsius_to_fahrenheit.py @@ -10,6 +10,8 @@ def celsiustofahrenheitFunc(maxTemp=100, format='string'): celsius) + " degrees Celsius to degrees Fahrenheit =" solution = str(fahrenheit) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return celsius, fahrenheit diff --git a/mathgenerator/funcs/misc/common_factors.py b/mathgenerator/funcs/misc/common_factors.py index 62e8710..1a5cf7e 100644 --- a/mathgenerator/funcs/misc/common_factors.py +++ b/mathgenerator/funcs/misc/common_factors.py @@ -23,6 +23,8 @@ def commonFactorsFunc(maxVal=100, format='string'): problem = f"Common Factors of {a} and {b} = " solution = arr return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, arr diff --git a/mathgenerator/funcs/misc/complex_to_polar.py b/mathgenerator/funcs/misc/complex_to_polar.py index c57f045..82c6288 100644 --- a/mathgenerator/funcs/misc/complex_to_polar.py +++ b/mathgenerator/funcs/misc/complex_to_polar.py @@ -16,6 +16,8 @@ def complexToPolarFunc(minRealImaginaryNum=-20, if format == 'string': problem = f'{r}({a}theta + i{b}theta)' return problem, theta + elif format == 'latex': + return "Latex unavailable" else: return r, a, b, theta diff --git a/mathgenerator/funcs/misc/decimal_to_roman_numerals.py b/mathgenerator/funcs/misc/decimal_to_roman_numerals.py index ade0866..8e759b0 100644 --- a/mathgenerator/funcs/misc/decimal_to_roman_numerals.py +++ b/mathgenerator/funcs/misc/decimal_to_roman_numerals.py @@ -35,6 +35,8 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000, format='string'): if format == 'string': problem = "The number " + str(x) + " in Roman Numerals is: " return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return x, solution diff --git a/mathgenerator/funcs/misc/euclidian_norm.py b/mathgenerator/funcs/misc/euclidian_norm.py index b46efa5..c16adbb 100644 --- a/mathgenerator/funcs/misc/euclidian_norm.py +++ b/mathgenerator/funcs/misc/euclidian_norm.py @@ -12,6 +12,8 @@ def euclidianNormFunc(maxEltAmt=20, format='string'): if format == 'string': problem = f"Euclidian norm or L2 norm of the vector{vec} is:" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return vec, solution diff --git a/mathgenerator/funcs/misc/gcd.py b/mathgenerator/funcs/misc/gcd.py index edcc584..29a0b62 100644 --- a/mathgenerator/funcs/misc/gcd.py +++ b/mathgenerator/funcs/misc/gcd.py @@ -12,6 +12,8 @@ def gcdFunc(maxVal=20, format='string'): problem = f"GCD of {a} and {b} = " solution = str(x) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, x diff --git a/mathgenerator/funcs/misc/geometric_progression.py b/mathgenerator/funcs/misc/geometric_progression.py index effffe1..e252060 100644 --- a/mathgenerator/funcs/misc/geometric_progression.py +++ b/mathgenerator/funcs/misc/geometric_progression.py @@ -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( a, r, n_term, value_nth_term, sum_term, sum_till_nth_term) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return GP, n_term, sum_term, a, r, n_term, value_nth_term, sum_term, sum_till_nth_term diff --git a/mathgenerator/funcs/misc/hcf.py b/mathgenerator/funcs/misc/hcf.py index 996f05a..18fde54 100644 --- a/mathgenerator/funcs/misc/hcf.py +++ b/mathgenerator/funcs/misc/hcf.py @@ -12,6 +12,8 @@ def hcfFunc(maxVal=20, format='string'): problem = f"HCF of {a} and {b} = " solution = str(x) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, x diff --git a/mathgenerator/funcs/misc/is_leap_year.py b/mathgenerator/funcs/misc/is_leap_year.py index 3092a45..011aebc 100644 --- a/mathgenerator/funcs/misc/is_leap_year.py +++ b/mathgenerator/funcs/misc/is_leap_year.py @@ -21,6 +21,8 @@ def IsLeapYear(minNumber=1900, maxNumber=2099, format='string'): else: solution = "is not a leap year" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return year, ans diff --git a/mathgenerator/funcs/misc/lcm.py b/mathgenerator/funcs/misc/lcm.py index e47fdfd..6e8d1b7 100644 --- a/mathgenerator/funcs/misc/lcm.py +++ b/mathgenerator/funcs/misc/lcm.py @@ -15,6 +15,8 @@ def lcmFunc(maxVal=20, format='string'): problem = f"LCM of {a} and {b} =" solution = str(d) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, d diff --git a/mathgenerator/funcs/misc/minutes_to_hours.py b/mathgenerator/funcs/misc/minutes_to_hours.py index 6a7410b..35b680c 100644 --- a/mathgenerator/funcs/misc/minutes_to_hours.py +++ b/mathgenerator/funcs/misc/minutes_to_hours.py @@ -10,6 +10,8 @@ def minutesToHoursFunc(maxMinutes=999, format='string'): problem = f"Convert {minutes} minutes to Hours & Minutes" solution = f"{ansHours} hours and {ansMinutes} minutes" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return minutes, ansHours, ansMinutes diff --git a/mathgenerator/funcs/misc/prime_factors.py b/mathgenerator/funcs/misc/prime_factors.py index 3747305..2632e92 100644 --- a/mathgenerator/funcs/misc/prime_factors.py +++ b/mathgenerator/funcs/misc/prime_factors.py @@ -21,6 +21,8 @@ def primeFactorsFunc(minVal=1, maxVal=200, format='string'): problem = f"Find prime factors of {a}" solution = f"{factors}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, factors diff --git a/mathgenerator/funcs/misc/profit_loss_percent.py b/mathgenerator/funcs/misc/profit_loss_percent.py index a9fc293..16369e8 100644 --- a/mathgenerator/funcs/misc/profit_loss_percent.py +++ b/mathgenerator/funcs/misc/profit_loss_percent.py @@ -14,6 +14,8 @@ def profitLossPercentFunc(maxCP=1000, maxSP=1000, format='string'): if format == 'string': problem = f"{profitOrLoss} percent when CP = {cP} and SP = {sP} is: " return problem, str(percent) + elif format == 'latex': + return "Latex unavailable" else: return profitOrLoss, cP, sP, percent diff --git a/mathgenerator/funcs/misc/quotient_of_power_same_base.py b/mathgenerator/funcs/misc/quotient_of_power_same_base.py index ab52586..11777a1 100644 --- a/mathgenerator/funcs/misc/quotient_of_power_same_base.py +++ b/mathgenerator/funcs/misc/quotient_of_power_same_base.py @@ -12,6 +12,8 @@ def quotientOfPowerSameBaseFunc(maxBase=50, maxPower=10, format='string'): problem = f"The Quotient of {base}^{power1} and {base}^{power2} = " \ f"{base}^({power1}-{power2}) = {base}^{step}" return problem, str(solution) + elif format == 'latex': + return "Latex unavailable" else: return base, power1, power2, step, solution diff --git a/mathgenerator/funcs/misc/quotient_of_power_same_power.py b/mathgenerator/funcs/misc/quotient_of_power_same_power.py index a26c37e..429cbe4 100644 --- a/mathgenerator/funcs/misc/quotient_of_power_same_power.py +++ b/mathgenerator/funcs/misc/quotient_of_power_same_power.py @@ -12,6 +12,8 @@ def quotientOfPowerSamePowerFunc(maxBase=50, maxPower=10, format='string'): problem = f"The Quotient of {base1}^{power} and {base2}^{power} = " \ f"({base1}/{base2})^{power} = {step}^{power}" return problem, str(solution) + elif format == 'latex': + return "Latex unavailable" else: return base1, base2, power, step, solution diff --git a/mathgenerator/funcs/misc/signum_function.py b/mathgenerator/funcs/misc/signum_function.py index b8214b5..03f3d7a 100644 --- a/mathgenerator/funcs/misc/signum_function.py +++ b/mathgenerator/funcs/misc/signum_function.py @@ -14,6 +14,8 @@ def signumFunc(min=-999, max=999, format='string'): problem = "signum of " + str(a) + " is " + "=" solution = str(b) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b diff --git a/mathgenerator/funcs/misc/surds_comparison.py b/mathgenerator/funcs/misc/surds_comparison.py index 858e7c5..699418e 100644 --- a/mathgenerator/funcs/misc/surds_comparison.py +++ b/mathgenerator/funcs/misc/surds_comparison.py @@ -18,6 +18,8 @@ def surdsComparisonFunc(maxValue=100, maxRoot=10, format='string'): if format == 'string': problem = f"Fill in the blanks {radicand1}^(1/{degree1}) _ {radicand2}^(1/{degree2})" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return radicand1, degree1, radicand2, degree2, solution diff --git a/mathgenerator/funcs/statistics/combinations.py b/mathgenerator/funcs/statistics/combinations.py index b4a4786..a24d9b7 100644 --- a/mathgenerator/funcs/statistics/combinations.py +++ b/mathgenerator/funcs/statistics/combinations.py @@ -17,6 +17,8 @@ def combinationsFunc(maxlength=20, format='string'): if format == 'string': problem = f"Number of combinations from {a} objects picked {b} at a time " return problem, str(solution) + elif format == 'latex': + return "Latex unavailable" else: return a, b, solution diff --git a/mathgenerator/funcs/statistics/conditional_probability.py b/mathgenerator/funcs/statistics/conditional_probability.py index 359ae86..7be6083 100644 --- a/mathgenerator/funcs/statistics/conditional_probability.py +++ b/mathgenerator/funcs/statistics/conditional_probability.py @@ -24,6 +24,8 @@ def conditionalProbFunc(format='string'): P_disease, true_positive, true_negative) solution = str(answer) + "%" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return P_disease, true_positive, true_negative, answer diff --git a/mathgenerator/funcs/statistics/confidence_interval.py b/mathgenerator/funcs/statistics/confidence_interval.py index 4449ff3..e236d8a 100644 --- a/mathgenerator/funcs/statistics/confidence_interval.py +++ b/mathgenerator/funcs/statistics/confidence_interval.py @@ -34,6 +34,8 @@ def confidenceIntervalFunc(format='string'): [x for x in lst], lst_per[j]) solution = f'({upper}, {lower})' return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return [x for x in lst], lst_per[j], upper, lower diff --git a/mathgenerator/funcs/statistics/data_summary.py b/mathgenerator/funcs/statistics/data_summary.py index d07546a..1801b06 100644 --- a/mathgenerator/funcs/statistics/data_summary.py +++ b/mathgenerator/funcs/statistics/data_summary.py @@ -23,6 +23,8 @@ def dataSummaryFunc(number_values=15, minval=5, maxval=50, format='string'): str(random_list) solution = f"The Mean is {mean} , Standard Deviation is {standardDeviation}, Variance is {variance}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return random_list, mean, standardDeviation, variance diff --git a/mathgenerator/funcs/statistics/dice_sum_probability.py b/mathgenerator/funcs/statistics/dice_sum_probability.py index cdfe309..c05076b 100644 --- a/mathgenerator/funcs/statistics/dice_sum_probability.py +++ b/mathgenerator/funcs/statistics/dice_sum_probability.py @@ -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} =" solution = f"{count}/{6**a}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, count, 6**a diff --git a/mathgenerator/funcs/statistics/mean_median.py b/mathgenerator/funcs/statistics/mean_median.py index 187dc28..2e47f54 100644 --- a/mathgenerator/funcs/statistics/mean_median.py +++ b/mathgenerator/funcs/statistics/mean_median.py @@ -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" solution = f"Arithmetic mean of the series is {mean} and Arithmetic median of this series is {median}" return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return randomlist, mean, median diff --git a/mathgenerator/funcs/statistics/permutation.py b/mathgenerator/funcs/statistics/permutation.py index 6c1891b..7eaeebe 100644 --- a/mathgenerator/funcs/statistics/permutation.py +++ b/mathgenerator/funcs/statistics/permutation.py @@ -12,6 +12,8 @@ def permutationFunc(maxlength=20, format='string'): problem = f"Number of Permutations from {a} objects picked {b} at a time = " solution = str(answer) return problem, solution + elif format == 'latex': + return "Latex unavailable" else: return a, b, answer diff --git a/scripts/makeReadme.py b/scripts/makeReadme.py new file mode 100644 index 0000000..3681b04 --- /dev/null +++ b/scripts/makeReadme.py @@ -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("[[", "
| ") + string = string.replace("[", " | |
| ") + string = string.replace(", ", " | ") + string = string.replace("]]", " |