diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 49d0e4ce..6b307964 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -27,6 +27,3 @@ jobs:
- name: Linter
run: make lint
-
- - name: Test
- run: make test
diff --git a/Makefile b/Makefile
index eb91e5ee..aeaff99a 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,3 @@ format:
lint:
$(PYTHON) -m flake8 --ignore=$(IGNORE_ERRORS) $(PKG)
-
-test:
- $(PYTHON) -m pytest --verbose -s tests
diff --git a/README.md b/README.md
index deee72d3..f548e938 100644
--- a/README.md
+++ b/README.md
@@ -75,147 +75,147 @@ You can also use `getGenList()` to return a list of all generators included in t
## algebra
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------|
-| 11 | [Basic Algebra](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/basic_algebra.py) | 9x + 5 = 9 | 4/9 | basic_algebra | `maxVariable=10` |
-| 12 | [Logarithm](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/log.py) | log2(32) | 5 | log | `maxBase=3` `maxVal=8` |
-| 17 | [Integer Multiplication with 2x2 Matrix](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py) | 0 * [[8, 10], [1, 10]] = | [[0,0],[0,0]] | multiply_int_to_22_matrix | `maxMatrixVal=10` `maxRes=100` |
-| 20 | [Midpoint of the two point](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/midpoint_of_two_points.py) | (8,-9),(20,-14)= | (14.0,-11.5) | midpoint_of_two_points | `maxValue=20` |
-| 21 | [Factoring Quadratic](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/factoring.py) | x^2+x-30 | (x-5)(x+6) | factoring | `range_x1=10` `range_x2=10` |
-| 23 | [Solve a System of Equations in R^2](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/system_of_equations.py) | 10x - 10y = -10, 6x + 7y = 98 | x = 7, y = 8 | system_of_equations | `range_x=10` `range_y=10` `coeff_mult_range=10` |
-| 24 | [Distance between 2 points](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/distance_two_points.py) | Find the distance between (-10, 11) and (-2, 19) | sqrt(128) | distance_two_points | `maxValXY=20` `minValXY=-20` |
-| 26 | [Linear Equations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/linear_equations.py) | 5x + -11y = -44, 14x + 12y = -166 | x = -11, y = -1 | linear_equations | `n=2` `varRange=20` `coeffRange=20` |
-| 41 | [Intersection of Two Lines](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/intersection_of_two_lines.py) | Find the point of intersection of the two lines: y = -9x - 9 and y = -6/3x + 2 | (-11/7, 36/7) | intersection_of_two_lines | `minM=-10` `maxM=10` `minB=-10` `maxB=10` `minDenominator=1` `maxDenominator=6` |
-| 43 | [Cross Product of 2 Vectors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/vector_cross.py) | [6, -20, 10] X [-13, 12, -19] = | [260, -16, -188] | vector_cross | `minVal=-20` `maxVal=20` |
-| 45 | [Simple Interest](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/simple_interest.py) | Simple interest for a principle amount of 3854 dollars, 2% rate of interest and for a time period of 3 years is = | 231.24 | simple_interest | `maxPrinciple=10000` `maxRate=10` `maxTime=10` |
-| 46 | [Multiplication of two matrices](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/matrix_multiplication.py) | Multiply
and | | matrix_multiplication | `maxVal=100` `max_dim=10` |
-| 50 | [Quadratic Equation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/quadratic_equation.py) | Zeros of the Quadratic Equation 78x^2+156x+38=0 | [-0.28, -1.72] | quadratic_equation | `maxVal=100` |
-| 65 | [Multiplication of 2 complex numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/multiply_complex_numbers.py) | (-2-13j) * (-15-11j) = | (-113+217j) | multiply_complex_numbers | `minRealImaginaryNum=-20` `maxRealImaginaryNum=20` |
-| 72 | [Dot Product of 2 Vectors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/vector_dot.py) | [-4, 7, -3] . [-10, 9, -16] = | 151 | vector_dot | `minVal=-20` `maxVal=20` |
-| 74 | [Inverse of a Matrix](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/invert_matrix.py) | Inverse of Matrix Matrix([[5, 89, 34], [43, 21, 47], [3, 86, 7]]) is: | Matrix([[-779/17975, 2301/89875, 3469/89875], [-32/17975, -67/89875, 1227/89875], [727/17975, -163/89875, -3722/89875]]) | invert_matrix | `SquareMatrixDimension=3` `MaxMatrixElement=99` `OnlyIntegerElementsInInvertedMatrix=False` |
-| 77 | [Determinant to 2x2 Matrix](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/int_matrix_22_determinant.py) | Det([[77, 20], [68, 89]]) = | 5493 | int_matrix_22_determinant | `maxMatrixVal=100` |
-| 78 | [Compound Interest](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/compound_interest.py) | Compound interest for a principle amount of 8503 dollars, 10% rate of interest and for a time period of 10 year is = | 22054.59 | compound_interest | `maxPrinciple=10000` `maxRate=10` `maxTime=10` |
-| 100 | [complex Quadratic Equation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/complex_quadratic.py) | Find the roots of given Quadratic Equation 5x^2 + 8x + 2 = 0 | simplified solution : ((-0.31, -1.29)), generalized solution : ((-8 + sqrt(24))/2*5, (-8 - sqrt(24))/2*5) | complex_quadratic | `prob_type=0` `max_range=10` |
-| 105 | [Combine Like terms](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/combine_like_terms.py) | 1x^5 + 10x^1 + 2x^1 + 3x^2 + 5x^1 + 4x^2 + 2x^3 | 17x^1 + 7x^2 + 2x^3 + 1x^5 | combine_like_terms | `maxCoef=10` `maxExp=20` `maxTerms=10` |
-| 111 | [Expanding Factored Binomial](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/expanding.py) | (7x-2)(+6x-3) | 42*x^2-33*x+6 | expanding | `range_x1=10` `range_x2=10` `range_a=10` `range_b=10` |
+| 11 | [Basic Algebra](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/basic_algebra.py) | $9x + 9 = 9$ | $0$ | basic_algebra | `maxVariable=10` |
+| 12 | [Logarithm](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/log.py) | $log_{2}(256)=$ | $8$ | log | `maxBase=3` `maxVal=8` |
+| 17 | [Integer Multiplication with 2x2 Matrix](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py) | $2 * \begin{bmatrix} 8 & 0 \\ 10 & 10 \end{bmatrix} =$ | $\begin{bmatrix} 16 & 0 \\ 20 & 20 \end{bmatrix}$ | multiply_int_to_22_matrix | `maxMatrixVal=10` `maxRes=100` |
+| 20 | [Midpoint of the two point](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/midpoint_of_two_points.py) | The midpoint of $(7,5)$ and $(-17,14) = $ | $(-5.0,9.5)$ | midpoint_of_two_points | `maxValue=20` |
+| 21 | [Factoring Quadratic](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/factoring.py) | $x^2-2x$ | $(x)(x-2)$ | factoring | `range_x1=10` `range_x2=10` |
+| 23 | [Solve a System of Equations in R^2](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/system_of_equations.py) | Given $4x - 6y = 36$ and $9x - 2y = 12$, solve for $x$ and $y$. | $x = 0$, $y = -6$ | system_of_equations | `range_x=10` `range_y=10` `coeff_mult_range=10` |
+| 24 | [Distance between 2 points](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/distance_two_points.py) | Find the distance between $(7, -15)$ and $(0, -1)$ | $\sqrt{245}$ | distance_two_points | `maxValXY=20` `minValXY=-20` |
+| 26 | [Linear Equations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/linear_equations.py) | Given the equations $-3x + 10y = -140$ and $-3x + -4y = -28$, solve for $x$ and $y$ | $x = 20$, $y = -8$ | linear_equations | `n=2` `varRange=20` `coeffRange=20` |
+| 41 | [Intersection of Two Lines](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/intersection_of_two_lines.py) | Find the point of intersection of the two lines: $y = 9/3x - 6$ and $y = 1/3x + 6$ | $(9/2, 15/2)$ | intersection_of_two_lines | `minM=-10` `maxM=10` `minB=-10` `maxB=10` `minDenominator=1` `maxDenominator=6` |
+| 43 | [Cross Product of 2 Vectors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/vector_cross.py) | $[-18, 0, 20] \times [-16, -5, 0] = $ | $[100, -320, 90]$ | vector_cross | `minVal=-20` `maxVal=20` |
+| 45 | [Simple Interest](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/simple_interest.py) | Simple interest for a principle amount of $9080$ dollars, $3$% rate of interest and for a time period of $6$ years is $=$ | $1634.4$ | simple_interest | `maxPrinciple=10000` `maxRate=10` `maxTime=10` |
+| 46 | [Multiplication of two matrices](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/matrix_multiplication.py) | Multiply$\begin{bmatrix}0&-1&-9&1\\-10&4&3&-10\end{bmatrix}$and$\begin{bmatrix}-4&-2&-4\\8&-1&2\\-2&6&-5\\-10&7&5\end{bmatrix}$ | $\begin{bmatrix}0&-46&48\\166&-36&-17\end{bmatrix}$ | matrix_multiplication | `maxVal=100` `max_dim=10` |
+| 50 | [Quadratic Equation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/quadratic_equation.py) | What are the zeros of the quadratic equation $24x^2+103x+26=0$ | ${-0.27, -4.02}$ | quadratic_equation | `maxVal=100` |
+| 65 | [Multiplication of 2 complex numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/multiply_complex_numbers.py) | $(17+1j) * (17-1j) = $ | $(290+0j)$ | multiply_complex_numbers | `minRealImaginaryNum=-20` `maxRealImaginaryNum=20` |
+| 72 | [Dot Product of 2 Vectors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/vector_dot.py) | $[9, 14, -19]\cdot[-8, -9, 10]=$ | $-388$ | vector_dot | `minVal=-20` `maxVal=20` |
+| 74 | [Inverse of a Matrix](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/invert_matrix.py) | Inverse of Matrix $\begin{bmatrix} 0 & 0 & 1 \\ 1 & 3 & 3 \\ 1 & 2 & 2 \end{bmatrix}$ is: | \begin{bmatrix} 0 & -2 & 3 \\ -1 & 1 & -1 \\ 1 & 0 & 0 \end{bmatrix} | invert_matrix | `SquareMatrixDimension=3` `MaxMatrixElement=99` `OnlyIntegerElementsInInvertedMatrix=True` |
+| 77 | [Determinant to 2x2 Matrix](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/int_matrix_22_determinant.py) | $\det \begin{bmatrix} 24 & 94 \\ 21 & 29 \end{bmatrix}= $ | $-1278$ | int_matrix_22_determinant | `maxMatrixVal=100` |
+| 78 | [Compound Interest](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/compound_interest.py) | Compound interest for a principle amount of $2004$ dollars, $1$% rate of interest and for a time period of $5$ years is $=$ | $2106.22$ | compound_interest | `maxPrinciple=10000` `maxRate=10` `maxTime=10` |
+| 100 | [complex Quadratic Equation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/complex_quadratic.py) | Find the roots of given Quadratic Equation $7x^2 + 7x + 1 = 0$ | $((-0.173, -0.827)) = (\frac{-7 + \sqrt{21}}{2*7}, (\frac{-7 - \sqrt{21}}{2*7})$ | complex_quadratic | `prob_type=0` `max_range=10` |
+| 105 | [Combine Like terms](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/combine_like_terms.py) | $4x^{13} + 1x^{16}$ | $4x^{13} + 1x^{16}$ | combine_like_terms | `maxCoef=10` `maxExp=20` `maxTerms=10` |
+| 111 | [Expanding Factored Binomial](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/algebra/expanding.py) | $(-10x-2)(-1x+6)$ | $10x^2-58x-12$ | expanding | `range_x1=10` `range_x2=10` `range_a=10` `range_b=10` |
## basic_math
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------|
-| 0 | [Addition](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/addition.py) | 14+15= | 29 | addition | `maxSum=99` `maxAddend=50` |
-| 1 | [Subtraction](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/subtraction.py) | 55-55= | 0 | subtraction | `maxMinuend=99` `maxDiff=99` |
-| 2 | [Multiplication](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/multiplication.py) | 2*11= | 22 | multiplication | `maxMulti=12` |
-| 3 | [Division](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/division.py) | 156/12= | 13 | division | `maxA=25` `maxB=25` |
-| 6 | [Square Root](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/square_root.py) | sqrt(9)= | 3 | square_root | `minNo=1` `maxNo=12` |
-| 8 | [Square](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/square.py) | 8^2= | 64 | square | `maxSquareNum=20` |
-| 13 | [Fraction to Decimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/fraction_to_decimal.py) | 32/35= | 0.91 | fraction_to_decimal | `maxRes=99` `maxDivid=99` |
-| 16 | [Fraction Division](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/divide_fractions.py) | (9/10)/(10/4) | 9/25 | divide_fractions | `maxVal=10` |
-| 28 | [Fraction Multiplication](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/fraction_multiplication.py) | (10/4)*(1/2) | 5/4 | fraction_multiplication | `maxVal=10` |
-| 31 | [Factorial](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/factorial.py) | 5! = | 120 | factorial | `maxInput=6` |
-| 44 | [Compare Fractions](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/compare_fractions.py) | Which symbol represents the comparison between 7/6 and 1/5? | > | compare_fractions | `maxVal=10` |
-| 47 | [Cube Root](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/cube_root.py) | What is the cube root of 648 up to 2 decimal places? | 8.65 | cube_root | `minNo=1` `maxNo=1000` |
-| 53 | [Exponentiation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/exponentiation.py) | 7^9 = | 40353607 | exponentiation | `maxBase=20` `maxExpo=10` |
-| 71 | [Absolute difference between two numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/absolute_difference.py) | |-96--27|= | 69 | absolute_difference | `maxA=100` `maxB=100` |
-| 80 | [Percentage of a number](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage.py) | What is 61% of 38? | 23.18 | percentage | `maxValue=99` `maxpercentage=99` |
-| 90 | [isprime](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/is_prime.py) | Is 40 prime? | No | is_prime | `max_num=100` |
-| 97 | [Power of Powers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/power_of_powers.py) | Simplify 2^9^4= | 2^36 | power_of_powers | `maxBase=50` `maxPower=10` |
-| 118 | [Percentage difference](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage_difference.py) | What is the percentage difference between 160 and 190? | 17.14% | percentage_difference | `maxValue=200` `minValue=0` |
-| 119 | [Percentage error](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage_error.py) | Find the percentage error when observed value equals 27 and exact value equals 82. | 67.07% | percentage_error | `maxValue=100` `minValue=-100` |
-| 120 | [Greatest Common Divisor of N Numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/greatest_common_divisor.py) | GCD(850468745,474001818)= | 1 | greatest_common_divisor | `numbersCount=2` `maximalNumberLimit=10**9` |
-| 124 | [Is Composite](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/is_composite.py) | Is 231 composite? | Yes | is_composite | `maxNum=250` |
+| 0 | [Addition](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/addition.py) | $40+14=$ | $54$ | addition | `maxSum=99` `maxAddend=50` |
+| 1 | [Subtraction](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/subtraction.py) | $12-2=$ | $10$ | subtraction | `maxMinuend=99` `maxDiff=99` |
+| 2 | [Multiplication](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/multiplication.py) | $7\cdot8$ | $56$ | multiplication | `maxMulti=12` |
+| 3 | [Division](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/division.py) | $92\div23=$ | $4$ | division | `maxA=25` `maxB=25` |
+| 6 | [Square Root](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/square_root.py) | $\sqrt{1}=$ | $1$ | square_root | `minNo=1` `maxNo=12` |
+| 8 | [Square](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/square.py) | $9^2=$ | $81$ | square | `maxSquareNum=20` |
+| 13 | [Fraction to Decimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/fraction_to_decimal.py) | $84\div6=$ | $14.0$ | fraction_to_decimal | `maxRes=99` `maxDivid=99` |
+| 16 | [Fraction Division](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/divide_fractions.py) | $\frac{6}{7}\div\frac{9}{5}=$ | $\frac{10}{21}$ | divide_fractions | `maxVal=10` |
+| 28 | [Fraction Multiplication](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/fraction_multiplication.py) | $\frac{3}{9}\cdot\frac{7}{6}=$ | $\frac{7}{18}$ | fraction_multiplication | `maxVal=10` |
+| 31 | [Factorial](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/factorial.py) | $5! =$ | $120$ | factorial | `maxInput=6` |
+| 44 | [Compare Fractions](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/compare_fractions.py) | Which symbol represents the comparison between $\frac{3}{5}$ and $\frac{3}{9}$? | > | compare_fractions | `maxVal=10` |
+| 47 | [Cube Root](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/cube_root.py) | What is the cube root of: $\sqrt[3]{30}=$ to 2 decimal places? | $3.11$ | cube_root | `minNo=1` `maxNo=1000` |
+| 53 | [Exponentiation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/exponentiation.py) | $4^1 =$ | $4$ | exponentiation | `maxBase=20` `maxExpo=10` |
+| 71 | [Absolute difference between two numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/absolute_difference.py) | $|22--59|=$ | $81$ | absolute_difference | `maxA=100` `maxB=100` |
+| 80 | [Percentage of a number](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage.py) | What is $5$% of $18$? | $0.90$ | percentage | `maxValue=99` `maxpercentage=99` |
+| 90 | [isprime](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/is_prime.py) | Is $73$ prime? | Yes | is_prime | `max_num=100` |
+| 97 | [Power of Powers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/power_of_powers.py) | Simplify $31^{8^{2}}$ | $31^{16}$ | power_of_powers | `maxBase=50` `maxPower=10` |
+| 118 | [Percentage difference](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage_difference.py) | What is the percentage difference between $66$ and $7$? | $161.64$% | percentage_difference | `maxValue=200` `minValue=0` |
+| 119 | [Percentage error](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage_error.py) | Find the percentage error when observed value equals $-44$ and exact value equals $-26$. | $69.23\%$ | percentage_error | `maxValue=100` `minValue=-100` |
+| 120 | [Greatest Common Divisor of N Numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/greatest_common_divisor.py) | $GCD(860597057,541815762)=$ | $1$ | greatest_common_divisor | `numbersCount=2` `maximalNumberLimit=10**9` |
+| 124 | [Is Composite](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/is_composite.py) | Is $144$ composite? | Yes | is_composite | `maxNum=250` |
## calculus
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------|
-| 7 | [Power Rule Differentiation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/power_rule_differentiation.py) | 8x^4 + 7x^8 | 32x^3 + 56x^7 | power_rule_differentiation | `maxCoef=10` `maxExp=10` `maxTerms=5` |
-| 48 | [Power Rule Integration](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/power_rule_integration.py) | 5x^5 + 3x^7 + 7x^8 + 8x^6 | (5/5)x^6 + (3/7)x^8 + (7/8)x^9 + (8/6)x^7 + c | power_rule_integration | `maxCoef=10` `maxExp=10` `maxTerms=5` |
-| 88 | [Differentiation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/differentiation.py) | differentiate w.r.t x : d(sec(x)+7*x^2)/dx | 14*x + tan(x)*sec(x) | differentiation | `diff_lvl=2` |
-| 89 | [Definite Integral of Quadratic Equation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/definite_integral.py) | The definite integral within limits 0 to 1 of the equation 10x^2 + 70x + 10 is = | 48.3333 | definite_integral | `max_coeff=100` |
-| 110 | [Stationary Points](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/stationary_points.py) | f(x)=7*x^3 + 2*x | | stationary_points | `maxExp=3` `maxCoef=10` |
+| 7 | [Power Rule Differentiation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/power_rule_differentiation.py) | $2x^{6} + 5x^{4} + 6x^{4} + 9x^{4}$ | $12x^{5} + 20x^{3} + 24x^{3} + 36x^{3}$ | power_rule_differentiation | `maxCoef=10` `maxExp=10` `maxTerms=5` |
+| 48 | [Power Rule Integration](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/power_rule_integration.py) | $8x^{1} + 1x^{9} + 5x^{1}$ | $\frac{8}{1}x^{2} + \frac{1}{9}x^{10} + \frac{5}{1}x^{2} + C$ | power_rule_integration | `maxCoef=10` `maxExp=10` `maxTerms=5` |
+| 88 | [Trigonometric Differentiation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/trig_differentiation.py) | $\frac{d}{dx}(\sin)=$ | $\cos$ | trig_differentiation | |
+| 89 | [Definite Integral of Quadratic Equation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/definite_integral.py) | The definite integral within limits $0$ to $1$ of the equation $24x^2 + 93x + 13 = $ | $67.5$ | definite_integral | `max_coeff=100` |
+| 110 | [Stationary Points](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/calculus/stationary_points.py) | $f(x)=10*x^3 + 8*x^2 + 2*x + 5$ | ${- \frac{1}{3}, - \frac{1}{5}}$ | stationary_points | `maxExp=3` `maxCoef=10` |
## computer_science
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------|
-| 4 | [Binary Complement 1s](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_complement_1s.py) | 1000= | 0111 | binary_complement_1s | `maxDigits=10` |
-| 5 | [Modulo Division](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/modulo_division.py) | 25%15= | 10 | modulo_division | `maxRes=99` `maxModulo=99` |
-| 14 | [Decimal to Binary](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_binary.py) | Binary of 72= | 1001000 | decimal_to_binary | `max_dec=99` |
-| 15 | [Binary to Decimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_to_decimal.py) | 1 | 1 | binary_to_decimal | `max_dig=10` |
-| 56 | [Fibonacci Series](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/fibonacci_series.py) | The Fibonacci Series of the first 11 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] | fibonacci_series | `minNo=1` |
-| 62 | [nth Fibonacci number](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/nth_fibonacci_number.py) | What is the 85th Fibonacci number? | 259695496911123328 | nth_fibonacci_number | `maxN=100` |
-| 64 | [Binary to Hexidecimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_to_hex.py) | 001 | 0x1 | binary_to_hex | `max_dig=10` |
-| 73 | [Binary 2's Complement](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_2s_complement.py) | 2's complement of 1011011001 = | 100100111 | binary_2s_complement | `maxDigits=10` |
-| 79 | [Decimal to Hexadecimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py) | Binary of 545= | 0x221 | decimal_to_hexadeci | `max_dec=1000` |
-| 84 | [Converts decimal to octal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_octal.py) | The decimal number 470 in Octal is: | 0o726 | decimal_to_octal | `maxDecimal=4096` |
-| 91 | [Binary Coded Decimal to Integer](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/bcd_to_decimal.py) | Integer of Binary Coded Decimal 6 is = | 25205 | bcd_to_decimal | `maxNumber=10000` |
-| 103 | [Decimal to Binary Coded Decimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_bcd.py) | BCD of Decimal Number 4491 is = | 11811 | decimal_to_bcd | `maxNumber=10000` |
+| 4 | [Binary Complement 1s](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_complement_1s.py) | $010 = $ | $101$ | binary_complement_1s | `maxDigits=10` |
+| 5 | [Modulo Division](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/modulo_division.py) | $84$ % $20 = $ | $4$ | modulo_division | `maxRes=99` `maxModulo=99` |
+| 14 | [Decimal to Binary](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_binary.py) | Binary of $49 = $ | $110001$ | decimal_to_binary | `max_dec=99` |
+| 15 | [Binary to Decimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_to_decimal.py) | $00$ | $0$ | binary_to_decimal | `max_dig=10` |
+| 56 | [Fibonacci Series](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/fibonacci_series.py) | The Fibonacci Series of the first ${n}$ numbers is ? | $0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89$ | fibonacci_series | `minNo=1` |
+| 62 | [nth Fibonacci number](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/nth_fibonacci_number.py) | What is the 74th Fibonacci number? | $1304969544928660$ | nth_fibonacci_number | `maxN=100` |
+| 64 | [Binary to Hexidecimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_to_hex.py) | $11010100$ | $0xd4$ | binary_to_hex | `max_dig=10` |
+| 73 | [Binary 2's Complement](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/binary_2s_complement.py) | 2's complement of $1 = $ | $1$ | binary_2s_complement | `maxDigits=10` |
+| 79 | [Decimal to Hexadecimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py) | Binary of $639 = $ | $0x27f$ | decimal_to_hexadeci | `max_dec=1000` |
+| 84 | [Converts decimal to octal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_octal.py) | The decimal number ${x}$ in Octal is: | $0o5206$ | decimal_to_octal | `maxDecimal=4096` |
+| 91 | [Binary Coded Decimal to Integer](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/bcd_to_decimal.py) | Integer of Binary Coded Decimal $3$ is $=$ | $12440$ | bcd_to_decimal | `maxNumber=10000` |
+| 103 | [Decimal to Binary Coded Decimal](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/computer_science/decimal_to_bcd.py) | BCD of Decimal Number $6981 = $ | $11145$ | decimal_to_bcd | `maxNumber=10000` |
## geometry
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------|
-| 18 | [Area of Triangle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_triangle.py) | Area of triangle with side lengths: 6 20 22 = | 58.79 | area_of_triangle | `maxA=20` `maxB=20` |
-| 19 | [Triangle exists check](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/valid_triangle.py) | Does triangle with sides 38, 28 and 27 exist? | Yes | valid_triangle | `maxSideLength=50` |
-| 22 | [Third Angle of Triangle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/third_angle_of_triangle.py) | Third angle of triangle with angles 14 and 63 = | 103 | third_angle_of_triangle | `maxAngle=89` |
-| 25 | [Pythagorean Theorem](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/pythagorean_theorem.py) | The hypotenuse of a right triangle given the other two lengths 9 and 4 = | 9.85 | pythagorean_theorem | `maxLength=20` |
-| 29 | [Angle of a Regular Polygon](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/angle_regular_polygon.py) | Find the angle of a regular polygon with 11 sides | 147.27 | angle_regular_polygon | `minVal=3` `maxVal=20` |
-| 32 | [Surface Area of Cube](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cube.py) | Surface area of cube with side = 8m is | 384 m^2 | surface_area_cube | `maxSide=20` `unit='m'` |
-| 33 | [Surface Area of Cuboid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cuboid.py) | Surface area of cuboid with sides = 1m, 15m, 11m is | 382 m^2 | surface_area_cuboid | `maxSide=20` `unit='m'` |
-| 34 | [Surface Area of Cylinder](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cylinder.py) | Surface area of cylinder with height = 3m and radius = 17m is | 2136 m^2 | surface_area_cylinder | `maxRadius=20` `maxHeight=50` `unit='m'` |
-| 35 | [Volume of Cube](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cube.py) | Volume of cube with side = 9m is | 729 m^3 | volume_cube | `maxSide=20` `unit='m'` |
-| 36 | [Volume of Cuboid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cuboid.py) | Volume of cuboid with sides = 10m, 12m, 9m is | 1080 m^3 | volume_cuboid | `maxSide=20` `unit='m'` |
-| 37 | [Volume of cylinder](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cylinder.py) | Volume of cylinder with height = 4m and radius = 15m is | 2827 m^3 | volume_cylinder | `maxRadius=20` `maxHeight=50` `unit='m'` |
-| 38 | [Surface Area of cone](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cone.py) | Surface area of cone with height = 26m and radius = 15m is | 2121 m^2 | surface_area_cone | `maxRadius=20` `maxHeight=50` `unit='m'` |
-| 39 | [Volume of cone](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cone.py) | Volume of cone with height = 31m and radius = 7m is | 1590 m^3 | volume_cone | `maxRadius=20` `maxHeight=50` `unit='m'` |
-| 49 | [Fourth Angle of Quadrilateral](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py) | Fourth angle of quadrilateral with angles 39 , 151, 137 = | 33 | fourth_angle_of_quadrilateral | `maxAngle=180` |
-| 57 | [Trigonometric Values](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/basic_trigonometry.py) | What is tan(45)? | 1 | basic_trigonometry | `angles=[0, 30, 45, 60, 90]` `functions=['sin', 'cos', 'tan']` |
-| 58 | [Sum of Angles of Polygon](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/sum_of_polygon_angles.py) | Sum of angles of polygon with 5 sides = | 540 | sum_of_polygon_angles | `maxSides=12` |
-| 60 | [Surface Area of Sphere](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_sphere.py) | Surface area of Sphere with radius = 19m is | 4536.459791783661 m^2 | surface_area_sphere | `maxSide=20` `unit='m'` |
-| 61 | [Volume of Sphere](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_sphere.py) | Volume of sphere with radius 92 m = | 3261760.666984705 m^3 | volume_sphere | `maxRadius=100` |
-| 70 | [Angle between 2 vectors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/angle_btw_vectors.py) | angle between the vectors [497.44, 781.23, 668.33, 665.31, 359.43, 287.08, 844.18, 596.49, 367.01, 674.44, 524.18, 217.7, 698.12] and [909.53, 70.04, 869.99, 53.15, 508.12, 404.16, 470.25, 955.48, 868.15, 987.99, 480.44, 354.16, 742.91] is: | 0.58 radians | angle_btw_vectors | `maxEltAmt=20` |
-| 75 | [Area of a Sector](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/sector_area.py) | Given radius, 28 and angle, 255. Find the area of the sector. | Area of sector = 1744.63112 | sector_area | `maxRadius=49` `maxAngle=359` |
-| 86 | [Degrees to Radians](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/degree_to_rad.py) | Angle 47 in radians is = | 0.82 | degree_to_rad | `max_deg=360` |
-| 87 | [Radians to Degrees](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/radian_to_deg.py) | Angle 0 in degrees is = | 0.0 | radian_to_deg | `max_rad=3` |
-| 95 | [Curved surface area of a cylinder](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py) | What is the curved surface area of a cylinder of radius, 23 and height, 27? | CSA of cylinder = 3901.86 | curved_surface_area_cylinder | `maxRadius=49` `maxHeight=99` |
-| 96 | [Perimeter of Polygons](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/perimeter_of_polygons.py) | The perimeter of a 10 sided polygon with lengths of [58, 17, 71, 60, 116, 104, 35, 71, 105, 116]cm is: | 753 | perimeter_of_polygons | `maxSides=12` `maxLength=120` |
-| 104 | [Circumference](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/circumference.py) | Circumference of circle with radius 15 | 94.24777960769379 | circumference | `maxRadius=100` |
-| 108 | [Arc length of Angle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/arc_length.py) | Given radius, 37 and angle, 201. Find the arc length of the angle. | Arc length of the angle = 129.80014 | arc_length | `maxRadius=49` `maxAngle=359` |
-| 112 | [Area of Circle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_circle.py) | Area of circle with radius 91 | 26026.0 | area_of_circle | `maxRadius=100` |
-| 113 | [Volume of frustum](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_frustum.py) | Volume of frustum with height = 40m and r1 = 6m is and r2 = 6m is | 21404.0 m^3 | volume_frustum | `maxR1=20` `maxR2=20` `maxHeight=50` `unit='m'` |
-| 114 | [Equation of line from two points](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py) | What is the equation of the line between points (10,4) and (14,15) in slope-intercept form? | 4y = 11x -94 | equation_of_line_from_two_points | `maxCoordinate=20` `minCoordinate=-20` |
-| 115 | [Area of Circle given center and a point on circle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py) | Area of circle with center (10,7) and passing through (14.86, 14.57) is | 254.47 | area_of_circle_given_center_and_point | `maxCoordinate = 10` `maxRadius=10` |
-| 117 | [Volume of Hemisphere](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_hemisphere.py) | Volume of hemisphere with radius 39 m = | 124237.423 m^3 | volume_hemisphere | `maxRadius=100` |
-| 122 | [Volume of pyramid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_pyramid.py) | Volume of pyramid with base length = 15 m, base width = 13 m and height = 37 m is | 2405.0 m^3 | volume_pyramid | `maxLength=20` `maxWidth=20` `maxHeight=50` `unit='m'` |
-| 123 | [Surface area of pyramid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_pyramid.py) | Surface area of pyramid with base length = 40m, base width = 40m, and height = 16m | 2560 m^2 | surface_area_pyramid | `unit='m'` |
-| 125 | [Complementary and Supplementary Angle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/complementary_and_supplementary_angle.py) | The supplementary angle of 60 = | 120 | complementary_and_supplementary_angle | `maxSupp=180` `maxComp=90` |
+| 18 | [Area of Triangle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_triangle.py) | Area of triangle with side lengths: $5, 15 11 = $ | $19.14$ | area_of_triangle | `maxA=20` `maxB=20` |
+| 19 | [Triangle exists check](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/valid_triangle.py) | Does triangle with sides $20, 17$ and $29$ exist? | $Yes$ | valid_triangle | `maxSideLength=50` |
+| 22 | [Third Angle of Triangle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/third_angle_of_triangle.py) | Third angle of triangle with angles $1$ and $86 = $ | $93$ | third_angle_of_triangle | `maxAngle=89` |
+| 25 | [Pythagorean Theorem](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/pythagorean_theorem.py) | What is the hypotenuse of a right triangle given the other two sides have lengths $18$ and $9$? | $20.12$ | pythagorean_theorem | `maxLength=20` |
+| 29 | [Angle of a Regular Polygon](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/angle_regular_polygon.py) | Find the angle of a regular polygon with $7$ sides | $128.57$ | angle_regular_polygon | `minVal=3` `maxVal=20` |
+| 32 | [Surface Area of Cube](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cube.py) | Surface area of cube with side $= 17m$ is | $1734 m^2$ | surface_area_cube | `maxSide=20` `unit='m'` |
+| 33 | [Surface Area of Cuboid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cuboid.py) | Surface area of cuboid with sides of lengths: $9m, 11m, 20m$ is | $998 m^2$ | surface_area_cuboid | `maxSide=20` `unit='m'` |
+| 34 | [Surface Area of Cylinder](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cylinder.py) | Surface area of cylinder with height $= 25m$ and radius $= 18m$ is | $4863 m^2$ | surface_area_cylinder | `maxRadius=20` `maxHeight=50` `unit='m'` |
+| 35 | [Volume of Cube](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cube.py) | Volume of cube with a side length of $13m$ is | $2197 m^3$ | volume_cube | `maxSide=20` `unit='m'` |
+| 36 | [Volume of Cuboid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cuboid.py) | Volume of cuboid with sides = $2m, 6m, 18m$ is | $216 m^3$ | volume_cuboid | `maxSide=20` `unit='m'` |
+| 37 | [Volume of cylinder](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cylinder.py) | Volume of cylinder with height $= 28m$ and radius $= 5m$ is | $2199 m^3$ | volume_cylinder | `maxRadius=20` `maxHeight=50` `unit='m'` |
+| 38 | [Surface Area of cone](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_cone.py) | Surface area of cone with height $= 37m$ and radius $= 15m$ is | $2588 m^2$ | surface_area_cone | `maxRadius=20` `maxHeight=50` `unit='m'` |
+| 39 | [Volume of cone](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_cone.py) | Volume of cone with height $= 17m$ and radius $= 1m$ is | $17 m^3$ | volume_cone | `maxRadius=20` `maxHeight=50` `unit='m'` |
+| 49 | [Fourth Angle of Quadrilateral](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py) | Fourth angle of quadrilateral with angles $108 , 35, 117 =$ | $100$ | fourth_angle_of_quadrilateral | `maxAngle=180` |
+| 57 | [Trigonometric Values](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/basic_trigonometry.py) | $\tan(0) = $ | $0$ | basic_trigonometry | `angles=[0, 30, 45, 60, 90]` `functions=['sin', 'cos', 'tan']` |
+| 58 | [Sum of Angles of Polygon](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/sum_of_polygon_angles.py) | What is the sum of interior angles of a polygon with $5$ sides? | $540$ | sum_of_polygon_angles | `maxSides=12` |
+| 60 | [Surface Area of Sphere](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_sphere.py) | Surface area of Sphere with radius $= 14m$ is | $2463.0086404143976 m^2$ | surface_area_sphere | `maxSide=20` `unit='m'` |
+| 61 | [Volume of Sphere](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_sphere.py) | Volume of sphere with radius $12 m = $ | $7238.229473870882 m^3$ | volume_sphere | `maxRadius=100` |
+| 70 | [Angle between 2 vectors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/angle_btw_vectors.py) | angle between the vectors $[90.18, 778.39, 6.95, 189.4, 402.86]$ and $[937.62, 966.01, 986.87, 311.51, 725.29]$ is: | $0.77$ radians | angle_btw_vectors | `maxEltAmt=20` |
+| 75 | [Area of a Sector](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/sector_area.py) | What is the area of a sector with radius $27$ and angle $340$ degrees? | $2162.99$ | sector_area | `maxRadius=49` `maxAngle=359` |
+| 86 | [Degrees to Radians](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/degree_to_rad.py) | Angle $50$ degrees in radians is: | $0.87$ | degree_to_rad | `max_deg=360` |
+| 87 | [Radians to Degrees](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/radian_to_deg.py) | Angle $1.14$ radians in degrees is: | $65.32$ | radian_to_deg | `max_rad=6.28` |
+| 95 | [Curved surface area of a cylinder](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py) | What is the curved surface area of a cylinder of radius, $42$ and height, $28$? | $7389.03$ | curved_surface_area_cylinder | `maxRadius=49` `maxHeight=99` |
+| 96 | [Perimeter of Polygons](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/perimeter_of_polygons.py) | The perimeter of a $11$ sided polygon with lengths of $16, 109, 106, 37, 3, 59, 49, 1, 88, 43, 42$cm is: | $553$ | perimeter_of_polygons | `maxSides=12` `maxLength=120` |
+| 104 | [Circumference](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/circumference.py) | Circumference of circle with radius $37 = $ | $232.48$ | circumference | `maxRadius=100` |
+| 108 | [Arc length of Angle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/arc_length.py) | Given radius, $49$ and angle, $13$. Find the arc length of the angle. | Arc length of the angle $= 11.11775$ | arc_length | `maxRadius=49` `maxAngle=359` |
+| 112 | [Area of Circle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_circle.py) | Area of circle with radius $92=$ | $26590.44$ | area_of_circle | `maxRadius=100` |
+| 113 | [Volume of frustum](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_frustum.py) | Volume of frustum with height $= 33m$ and $r1 = 7m$ is and $r2 = 7m$ is | $6669.0 m^3$ | volume_frustum | `maxR1=20` `maxR2=20` `maxHeight=50` `unit='m'` |
+| 114 | [Equation of line from two points](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py) | What is the equation of the line between points $(20,7)$ and $(-12,12)$ in slope-intercept form? | $32y = -5x + 324$ | equation_of_line_from_two_points | `maxCoordinate=20` `minCoordinate=-20` |
+| 115 | [Area of Circle given center and a point on circle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py) | Area of circle with center $(-8,9)$ and passing through $(-4.0, 9.0)$ is | $50.27$ | area_of_circle_given_center_and_point | `maxCoordinate = 10` `maxRadius=10` |
+| 117 | [Volume of Hemisphere](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_hemisphere.py) | Volume of hemisphere with radius $25 m =$ | $32724.923 m^3$ | volume_hemisphere | `maxRadius=100` |
+| 122 | [Volume of pyramid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_pyramid.py) | Volume of pyramid with base length $= 3 m$, base width $= 1 m$ and height $= 2 m$ is | $2.0 m^3$ | volume_pyramid | `maxLength=20` `maxWidth=20` `maxHeight=50` `unit='m'` |
+| 123 | [Surface area of pyramid](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/surface_area_pyramid.py) | Surface area of pyramid with base length $= 6m$, base width $= 6m$, and height $= 4m$ is | $96 m^2$ | surface_area_pyramid | `unit='m'` |
+| 125 | [Complementary and Supplementary Angle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/complementary_and_supplementary_angle.py) | The supplementary angle of 48 = | 132 | complementary_and_supplementary_angle | `maxSupp=180` `maxComp=90` |
## misc
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------|
-| 9 | [LCM (Least Common Multiple)](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/lcm.py) | LCM of 8 and 17 = | 136 | lcm | `maxVal=20` |
-| 10 | [GCD (Greatest Common Denominator)](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/gcd.py) | GCD of 12 and 6 = | 6 | gcd | `maxVal=20` |
-| 27 | [Prime Factorisation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/prime_factors.py) | Find prime factors of 151 | [151] | prime_factors | `minVal=1` `maxVal=200` |
-| 40 | [Common Factors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/common_factors.py) | Common Factors of 8 and 95 = | [1] | common_factors | `maxVal=100` |
-| 51 | [HCF (Highest Common Factor)](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/hcf.py) | HCF of 16 and 3 = | 1 | hcf | `maxVal=20` |
-| 55 | [Comparing surds](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/surds_comparison.py) | Fill in the blanks 84^(1/6) _ 97^(1/1) | < | surds_comparison | `maxValue=100` `maxRoot=10` |
-| 63 | [Profit or Loss Percent](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/profit_loss_percent.py) | Profit percent when CP = 258 and SP = 601 is: | 132.9457364341085 | profit_loss_percent | `maxCP=1000` `maxSP=1000` |
-| 66 | [Geometric Progression](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/geometric_progression.py) | For the given GP [7, 14, 28, 56, 112, 224] ,Find the value of a,common ratio,7th term value, sum upto 11th term | The value of a is 7, common ratio is 2 , 7th term is 448 , sum upto 11th term is 14329.0 | geometric_progression | `number_values=6` `min_value=2` `max_value=12` `n_term=7` `sum_term=5` |
-| 67 | [Geometric Mean of N Numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/geometric_mean.py) | Geometric mean of 2 numbers 58 and 61 = | (58*61)^(1/2) = 59.481089431852205 | geometric_mean | `maxValue=100` `maxNum=4` |
-| 68 | [Harmonic Mean of N Numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/harmonic_mean.py) | Harmonic mean of 3 numbers 65 , 98 and 30 = | 3/((1/65) + (1/98) + (1/30)) = 50.91474245115453 | harmonic_mean | `maxValue=100` `maxNum=4` |
-| 69 | [Euclidian norm or L2 norm of a vector](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/euclidian_norm.py) | Euclidian norm or L2 norm of the vector[666.3121024557763, 339.3827343783811, 598.1073078463166, 514.5857680685369, 604.2767600509419, 642.5534920836018, 452.63625705604005, 833.1252882301409] is: | 1690.7649282758944 | euclidian_norm | `maxEltAmt=20` |
-| 81 | [Celsius To Fahrenheit](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/celsius_to_fahrenheit.py) | Convert 76 degrees Celsius to degrees Fahrenheit = | 168.8 | celsius_to_fahrenheit | `maxTemp=100` |
-| 82 | [AP Term Calculation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/arithmetic_progression_term.py) | Find the term number 37 of the AP series: -100, -61, -22 ... | 1304 | arithmetic_progression_term | `maxd=100` `maxa=100` `maxn=100` |
-| 83 | [AP Sum Calculation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/arithmetic_progression_sum.py) | Find the sum of first 28 terms of the AP series: 81, 64, 47 ... | -4158.0 | arithmetic_progression_sum | `maxd=100` `maxa=100` `maxn=100` |
-| 85 | [Converts decimal to Roman Numerals](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/decimal_to_roman_numerals.py) | The number 0 in Roman Numerals is: | XIII | decimal_to_roman_numerals | `maxDecimal=4000` |
-| 92 | [Complex To Polar Form](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/complex_to_polar.py) | 18.6(11.0theta + i15.0theta) | 0.94 | complex_to_polar | `minRealImaginaryNum=-20, maxRealImaginaryNum=20` |
-| 93 | [Union,Intersection,Difference of Two Sets](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/set_operation.py) | Given the two sets a={9, 2, 3, 1} ,b={8, 6}.Find the Union,intersection,a-b,b-a and symmetric difference | Union is {1, 2, 3, 6, 8, 9},Intersection is set(), a-b is {9, 2, 3, 1},b-a is {8, 6}, Symmetric difference is {1, 2, 3, 6, 8, 9} | set_operation | `minval=3` `maxval=7` `n_a=4` `n_b=5` |
-| 94 | [Base Conversion](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/base_conversion.py) | Convert D6E8 from base 16 to base 10. | 55016 | base_conversion | `maxNum=60000` `maxBase=16` |
-| 98 | [Quotient of Powers with Same Base](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/quotient_of_power_same_base.py) | The Quotient of 46^9 and 46^1 = 46^(9-1) = 46^8 | 20047612231936 | quotient_of_power_same_base | `maxBase=50` `maxPower=10` |
-| 99 | [Quotient of Powers with Same Power](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/quotient_of_power_same_power.py) | The Quotient of 1^8 and 21^8 = (1/21)^8 = 0.047619047619047616^8 | 2.643903757924558e-11 | quotient_of_power_same_power | `maxBase=50` `maxPower=10` |
-| 101 | [Leap Year or Not](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/is_leap_year.py) | Year 1942 | is not a leap year | is_leap_year | `minNumber=1900` `maxNumber=2099` |
-| 102 | [Minute to Hour conversion](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/minutes_to_hours.py) | Convert 20 minutes to Hours & Minutes | 0 hours and 20 minutes | minutes_to_hours | `maxMinutes=999` |
-| 106 | [signum function](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/signum_function.py) | signum of -217 is = | -1 | signum_function | `min=-999` `max=999` |
-| 109 | [Binomial distribution](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/binomial_distribution.py) | A manufacturer of metal pistons finds that, on average, 34.16% of the pistons they manufacture are rejected because they are incorrectly sized. What is the probability that a batch of 11 pistons will contain no more than 9 rejected pistons? | 99.98 | binomial_distribution | `` |
-| 116 | [Factors of a number](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/factors.py) | Factors of 513 = | [1, 3, 9, 19, 27, 57, 171, 513] | factors | `maxVal=1000` |
-| 121 | [Product of scientific notations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/product_of_scientific_notations.py) | Product of scientific notations 2.39x10^78 and 9.75x10^44 = | 2.33x10^123 | product_of_scientific_notations | `minExpVal=-100` `maxExpVal=100` |
+| 9 | [LCM (Least Common Multiple)](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/lcm.py) | LCM of $11$ and $12 =$ | $132$ | lcm | `maxVal=20` |
+| 10 | [GCD (Greatest Common Denominator)](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/gcd.py) | GCD of $20$ and $9 = $ | $1$ | gcd | `maxVal=20` |
+| 27 | [Prime Factorisation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/prime_factors.py) | Find prime factors of $84$ | $2, 2, 3, 7$ | prime_factors | `minVal=1` `maxVal=200` |
+| 40 | [Common Factors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/common_factors.py) | Common Factors of $7$ and $44 = $ | $[1]$ | common_factors | `maxVal=100` |
+| 51 | [HCF (Highest Common Factor)](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/hcf.py) | HCF of $13$ and $5 = $ | $1$ | hcf | `maxVal=20` |
+| 55 | [Comparing surds](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/surds_comparison.py) | Fill in the blanks $23^{\frac{1}{9}}$ _ $63^{\frac{1}{2}}$ | $<$ | surds_comparison | `maxValue=100` `maxRoot=10` |
+| 63 | [Profit or Loss Percent](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/profit_loss_percent.py) | Profit percent when $CP = 145$ and $SP = 782$ is: | $439.31$ | profit_loss_percent | `maxCP=1000` `maxSP=1000` |
+| 66 | [Geometric Progression](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/geometric_progression.py) | For the given GP $[3, 36, 432, 5184, 62208, 746496]$. Find the value of a common ratio, 10th term value, sum upto 10th term | The value of a is $3$, common ratio is $12$ , 10th term is $15479341056$, sum upto 10th term is $16886553879.0$ | geometric_progression | `number_values=6` `min_value=2` `max_value=12` `n_term=7` `sum_term=5` |
+| 67 | [Geometric Mean of N Numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/geometric_mean.py) | Geometric mean of $3$ numbers $[15, 90, 74] = $ | $46.4$ | geometric_mean | `maxValue=100` `maxCount=4` |
+| 68 | [Harmonic Mean of N Numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/harmonic_mean.py) | Harmonic mean of $4$ numbers $4, 94, 70, 14 = $ | $40.42123738481791$ | harmonic_mean | `maxValue=100` `maxNum=4` |
+| 69 | [Euclidian norm or L2 norm of a vector](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/euclidian_norm.py) | Euclidian norm or L2 norm of the vector $[667.6348977529038, 679.4272834518646, 255.59424823283462, 642.7158651607829, 619.0578738657584, 693.3434890856785, 107.39417747607006]$ is: | $1503.75$ | euclidian_norm | `maxEltAmt=20` |
+| 81 | [Celsius To Fahrenheit](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/celsius_to_fahrenheit.py) | Convert $2$ degrees Celsius to degrees Fahrenheit | $35.6$ | celsius_to_fahrenheit | `maxTemp=100` |
+| 82 | [AP Term Calculation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/arithmetic_progression_term.py) | Find term number $67$ of the AP series: $56, 133, 210 ... $ | $5138$ | arithmetic_progression_term | `maxd=100` `maxa=100` `maxn=100` |
+| 83 | [AP Sum Calculation](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/arithmetic_progression_sum.py) | Find the sum of first $54$ terms of the AP series: $83, 42, 1 ... $ | $-54189.0$ | arithmetic_progression_sum | `maxd=100` `maxa=100` `maxn=100` |
+| 85 | [Converts decimal to Roman Numerals](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/decimal_to_roman_numerals.py) | The number $0$ in Roman Numerals is: | $MMCCCLVI$ | decimal_to_roman_numerals | `maxDecimal=4000` |
+| 92 | [Complex To Polar Form](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/complex_to_polar.py) | $17.12(2.0\theta + i17.0\theta)$ | $1.45$ | complex_to_polar | `minRealImaginaryNum=-20, maxRealImaginaryNum=20` |
+| 93 | [Union,Intersection,Difference of Two Sets](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/set_operation.py) | Given the two sets $a={2, 6, 8, 9, 10}$, $b={8, 10, 4}. Find the Union, intersection, a-b, b-a, and symmetric difference | Union is ${2, 4, 6, 8, 9, 10}$. Intersection is ${8, 10}$, a-b is ${9, 2, 6}$, b-a is ${4}$. Symmetric difference is ${2, 4, 6, 9}$. | set_operation | `minval=3` `maxval=7` `n_a=4` `n_b=5` |
+| 94 | [Base Conversion](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/base_conversion.py) | Convert $56371$ from base $10$ to base $5$. | $3300441$ | base_conversion | `maxNum=60000` `maxBase=16` |
+| 98 | [Quotient of Powers with Same Base](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/quotient_of_power_same_base.py) | The Quotient of $17^{1}$ and $17^{9} = $17^{1-9} = 17^{-8}$ | $1.4335360832968505e-10$ | quotient_of_power_same_base | `maxBase=50` `maxPower=10` |
+| 99 | [Quotient of Powers with Same Power](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/quotient_of_power_same_power.py) | The Quotient of $33^{4}$ and $23^{4} = (33/23)^4 = 1.434782608695652^{4}$ | $4.237838629793346$ | quotient_of_power_same_power | `maxBase=50` `maxPower=10` |
+| 101 | [Leap Year or Not](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/is_leap_year.py) | Is 1906 a leap year? | 1906 is not a leap year | is_leap_year | `minNumber=1900` `maxNumber=2099` |
+| 102 | [Minute to Hour conversion](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/minutes_to_hours.py) | Convert $381$ minutes to hours & minutes | $6$ hours and $21$ minutes | minutes_to_hours | `maxMinutes=999` |
+| 106 | [signum function](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/signum_function.py) | signum of 985 is = | $1$ | signum_function | `min=-999` `max=999` |
+| 109 | [Binomial distribution](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/binomial_distribution.py) | A manufacturer of metal pistons finds that, on average, $34.46$% of the pistons they manufacture are rejected because they are incorrectly sized. What is the probability that a batch of $10$ pistons will contain no more than $8$ rejected pistons? | $99.95$ | binomial_distribution | `` |
+| 116 | [Factors of a number](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/factors.py) | Factors of $949 = $ | $[1, 13, 73, 949]$ | factors | `maxVal=1000` |
+| 121 | [Product of scientific notations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/product_of_scientific_notations.py) | Product of scientific notations $7.83 \times 10^{-39}$ and $6.12 \times 10^{-95} = $ | $4.79 \times 10^{-133}$ | product_of_scientific_notations | `minExpVal=-100` `maxExpVal=100` |
## statistics
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------|
-| 30 | [Combinations of Objects](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/combinations.py) | Number of combinations from 13 objects picked 9 at a time | 715 | combinations | `maxlength=20` |
-| 42 | [Permutations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/permutation.py) | Number of Permutations from 11 objects picked 3 at a time = | 990 | permutation | `maxlength=20` |
-| 52 | [Probability of a certain sum appearing on faces of dice](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/dice_sum_probability.py) | If 2 dice are rolled at the same time, the probability of getting a sum of 4 = | 3/36 | dice_sum_probability | `maxDice=3` |
-| 54 | [Confidence interval For sample S](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/confidence_interval.py) | The confidence interval for sample [254, 295, 271, 281, 218, 270, 242, 274, 247, 202, 253, 226, 237, 296, 286, 214, 215, 240, 248, 283, 290, 205, 230, 251, 224, 227] with 90% confidence is | (258.3421056762939, 240.04250970832146) | confidence_interval | `` |
-| 59 | [Mean,Standard Deviation,Variance](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/data_summary.py) | Find the mean,standard deviation and variance for the data[21, 49, 37, 16, 24, 23, 18, 38, 50, 40, 13, 7, 29, 46, 41] | The Mean is 30.133333333333333 , Standard Deviation is 178.38222222222223, Variance is 13.35598076601723 | data_summary | `number_values=15` `minval=5` `maxval=50` |
-| 76 | [Mean and Median](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/mean_median.py) | Given the series of numbers [4, 5, 20, 30, 32, 42, 52, 56, 71, 86]. find the arithmatic mean and mdian of the series | Arithmetic mean of the series is 39.8 and Arithmetic median of this series is 37.0 | mean_median | `maxlen=10` |
-| 107 | [Conditional Probability](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/conditional_probability.py) | Someone tested positive for a nasty disease which only 1.84% of population have. Test sensitivity (true positive) is equal to SN= 95.07% whereas test specificity (true negative) SP= 95.68%. What is the probability that this guy really has that disease? | 29.2% | conditional_probability | `` |
+| 30 | [Combinations of Objects](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/combinations.py) | Find the number of combinations from $14$ objects picked $6$ at a time. | $3003$ | combinations | `maxlength=20` |
+| 42 | [Permutations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/permutation.py) | Number of Permutations from $17$ objects picked $6$ at a time is: | $8910720$ | permutation | `maxlength=20` |
+| 52 | [Probability of a certain sum appearing on faces of dice](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/dice_sum_probability.py) | If $3$ dice are rolled at the same time, the probability of getting a sum of $3 =$ | \frac{1}{216} | dice_sum_probability | `maxDice=3` |
+| 54 | [Confidence interval For sample S](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/confidence_interval.py) | The confidence interval for sample $[226, 260, 221, 245, 282, 274, 207, 299, 257, 211, 233, 239, 206, 208, 242, 224, 265, 287, 230, 276, 256, 237, 215, 291, 216, 251, 255, 229, 279, 275, 210, 203, 220, 292]$ with $95$% confidence is | $(254.41804694839914, 235.052541286895)$ | confidence_interval | `` |
+| 59 | [Mean,Standard Deviation,Variance](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/data_summary.py) | Find the mean,standard deviation and variance for the data $48, 38, 10, 5, 24, 46, 50, 17, 20, 13, 17, 14, 5, 20, 34$ | The Mean is $24.066666666666666$, Standard Deviation is $220.0622222222222$, Variance is $14.834494336586678$ | data_summary | `number_values=15` `minval=5` `maxval=50` |
+| 76 | [Mean and Median](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/mean_median.py) | Given the series of numbers $[6, 30, 32, 39, 42, 65, 72, 80, 84, 85]$. Find the arithmatic mean and mdian of the series | Arithmetic mean of the series is $53.5$ and Arithmetic median of this series is $53.5$ | mean_median | `maxlen=10` |
+| 107 | [Conditional Probability](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/statistics/conditional_probability.py) | Someone tested positive for a nasty disease which only $1.26\%$ of the population have. Test sensitivity (true positive) is equal to $SN=93.71$% whereas test specificity (true negative) $SP=90.62\%$. What is the probability that this guy really has that disease? | $11.31$% | conditional_probability | `` |
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 7b09b597..5ef5c042 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,5 +1,4 @@
pytest
-hypothesis
flake8
autopep8
sympy
diff --git a/mathgenerator/funcs/algebra/basic_algebra.py b/mathgenerator/funcs/algebra/basic_algebra.py
index 2585fcf3..30348f59 100644
--- a/mathgenerator/funcs/algebra/basic_algebra.py
+++ b/mathgenerator/funcs/algebra/basic_algebra.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxVariable=10, format='string'):
+def gen_func(maxVariable=10):
a = random.randint(1, maxVariable)
b = random.randint(1, maxVariable)
c = random.randint(b, maxVariable)
@@ -21,16 +21,9 @@ def calculate_gcd(x, y):
elif a == 1 or a == i:
x = f"{c - b}"
- if format == 'string':
- problem = f"{a}x + {b} = {c}"
- solution = x
- return problem, solution
- elif format == 'latex':
- problem = f"\\({a}x + {b} = {c}\\)"
- solution = "\\(" + x + "\\)"
- return problem, solution
- else:
- return a, b, c, x
+ problem = f"${a}x + {b} = {c}$"
+ solution = f"${x}$"
+ return problem, solution
basic_algebra = Generator("Basic Algebra", 11, gen_func,
diff --git a/mathgenerator/funcs/algebra/combine_like_terms.py b/mathgenerator/funcs/algebra/combine_like_terms.py
index da1c96a9..8ba93bf3 100644
--- a/mathgenerator/funcs/algebra/combine_like_terms.py
+++ b/mathgenerator/funcs/algebra/combine_like_terms.py
@@ -2,49 +2,22 @@
import random
-def gen_func(maxCoef=10, maxExp=20, maxTerms=10, format='string'):
+def gen_func(maxCoef=10, maxExp=20, maxTerms=10):
numTerms = random.randint(1, maxTerms)
- problem = ""
- solution = ""
- for i in range(numTerms):
- if i > 0:
- problem += " + "
- solution += " + "
- coefficient = random.randint(1, maxCoef)
- exponent = random.randint(1, max(numTerms - 1, 2))
-
- problem += str(coefficient) + "x^" + str(exponent)
-
- solution = combineTerms(problem)
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
+ coefs = [random.randint(1, maxCoef) for _ in range(numTerms)]
+ exponents = [random.randint(1, max(maxExp - 1, 2)) for _ in range(numTerms)]
-
-def combineTerms(string):
- each_terms = string.split("+")
- dict_power_wise_terms = {}
- for i in range(11):
- dict_power_wise_terms[i] = []
- for term in each_terms:
- term = term.split("^")
- appendee = term[0].split("x")[0]
- if len(term) == 1:
- dict_power_wise_terms[1].append(int(appendee))
+ problem = " + ".join([f"{coefs[i]}x^{{{exponents[i]}}}" for i in range(numTerms)])
+ d = {}
+ for i in range(numTerms):
+ if exponents[i] in d:
+ d[exponents[i]] += coefs[i]
else:
- dict_power_wise_terms[int(term[1])].append(int(appendee))
+ d[exponents[i]] = coefs[i]
+ solution = " + ".join([f"{d[k]}x^{{{k}}}" for k in sorted(d)])
- final_string = ''
- for i in range(11):
- if len(dict_power_wise_terms[i]) != 0:
- total = sum(dict_power_wise_terms[i])
- final_string += str(total) + "x^" + str(i) + " + "
- final_string = '+'.join(final_string.split("+")[:-1])
- return final_string
+ return f'${problem}$', f'${solution}$'
combine_like_terms = Generator("Combine Like terms", 105, gen_func,
diff --git a/mathgenerator/funcs/algebra/complex_quadratic.py b/mathgenerator/funcs/algebra/complex_quadratic.py
index de45a686..2e118b4b 100644
--- a/mathgenerator/funcs/algebra/complex_quadratic.py
+++ b/mathgenerator/funcs/algebra/complex_quadratic.py
@@ -39,16 +39,16 @@ def gen_func(prob_type=0, max_range=10, format='string'):
eq += str(c) + ' = 0'
- problem = 'Find the roots of given Quadratic Equation ' + eq
+ problem = f'Find the roots of given Quadratic Equation ${eq}$'
if d < 0:
sqrt_d = (-d)**0.5
if sqrt_d - int(sqrt_d) == 0:
sqrt_d = int(sqrt_d)
- solution = f'(({-b} + {sqrt_d}i)/2*{a}, ({-b} - {sqrt_d}i)/2*{a})'
+ solution = f'(\\frac{{{-b} + {sqrt_d}i}}{{2*{a}}}, \\frac{{{-b} - {sqrt_d}i}}{{2*{a}}})'
else:
- solution = f'(({-b} + sqrt({-d})i)/2*{a}, ({-b} - sqrt({-d})i)/2*{a})'
+ solution = f'(\\frac{{{-b} + \\sqrt{{{-d}}}i}}{{2*{a}}}, \\frac{{{-b} - \\sqrt{{{-d}}}i}}{{2*{a}}})'
return problem, solution
@@ -60,11 +60,11 @@ def gen_func(prob_type=0, max_range=10, format='string'):
if sqrt_d - int(sqrt_d) == 0:
sqrt_d = int(sqrt_d)
- g_sol = f'(({-b} + {sqrt_d})/2*{a}, ({-b} - {sqrt_d})/2*{a})'
+ g_sol = f'(\\frac{{{-b} + {sqrt_d}}}{{2*{a}}}, \\frac{{{-b} - {sqrt_d}}}{{2*{a}}})'
else:
- g_sol = f'(({-b} + sqrt({d}))/2*{a}, ({-b} - sqrt({d}))/2*{a})'
+ g_sol = f'(\\frac{{{-b} + \\sqrt{{{d}}}}}{{2*{a}}}, (\\frac{{{-b} - \\sqrt{{{d}}}}}{{2*{a}}})'
- solution = f'simplified solution : ({s_root1, s_root2}), generalized solution : ' + g_sol
+ solution = f'$({s_root1, s_root2}) = {g_sol}$'
return problem, solution
diff --git a/mathgenerator/funcs/algebra/compound_interest.py b/mathgenerator/funcs/algebra/compound_interest.py
index 79590917..f8964e6f 100644
--- a/mathgenerator/funcs/algebra/compound_interest.py
+++ b/mathgenerator/funcs/algebra/compound_interest.py
@@ -4,23 +4,14 @@
def gen_func(maxPrinciple=10000,
maxRate=10,
- maxTime=10,
- format='string'):
+ maxTime=10):
p = random.randint(1000, maxPrinciple)
r = random.randint(1, maxRate)
n = random.randint(1, maxTime)
a = round(p * (1 + r / 100)**n, 2)
- if format == 'string':
- problem = "Compound interest for a principle amount of " + \
- 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
+ problem = f"Compound interest for a principle amount of ${p}$ dollars, ${r}$% rate of interest and for a time period of ${n}$ years is $=$"
+ return problem, f'${a}$'
compound_interest = Generator(
diff --git a/mathgenerator/funcs/algebra/distance_two_points.py b/mathgenerator/funcs/algebra/distance_two_points.py
index d38e957e..883015d5 100644
--- a/mathgenerator/funcs/algebra/distance_two_points.py
+++ b/mathgenerator/funcs/algebra/distance_two_points.py
@@ -2,22 +2,17 @@
import random
-def gen_func(maxValXY=20, minValXY=-20, format='string'):
+def gen_func(maxValXY=20, minValXY=-20):
point1X = random.randint(minValXY, maxValXY + 1)
point1Y = random.randint(minValXY, maxValXY + 1)
point2X = random.randint(minValXY, maxValXY + 1)
point2Y = random.randint(minValXY, maxValXY + 1)
- distanceSq = (point1X - point2X)**2 + (point1Y - point2Y)**2
+ distanceSq = (point1X - point2X) ** 2 + (point1Y - point2Y) ** 2
- if 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
+ solution = f"$\\sqrt{{{distanceSq}}}$"
+ problem = f"Find the distance between $({point1X}, {point1Y})$ and $({point2X}, {point2Y})$"
+ return problem, solution
distance_two_points = Generator("Distance between 2 points", 24,
diff --git a/mathgenerator/funcs/algebra/expanding.py b/mathgenerator/funcs/algebra/expanding.py
index 47d0c3d3..31f79556 100644
--- a/mathgenerator/funcs/algebra/expanding.py
+++ b/mathgenerator/funcs/algebra/expanding.py
@@ -5,20 +5,19 @@
def gen_func(range_x1=10,
range_x2=10,
range_a=10,
- range_b=10,
- format='string'):
+ range_b=10):
x1 = random.randint(-range_x1, range_x1)
x2 = random.randint(-range_x2, range_x2)
a = random.randint(-range_a, range_a)
b = random.randint(-range_b, range_b)
def intParser(z):
- if (z == 0):
- return ""
if (z > 0):
- return "+" + str(z)
- if (z < 0):
- return "-" + str(abs(z))
+ return f"+{z}"
+ elif (z < 0):
+ return f"-{abs(z)}"
+ else:
+ return ""
c1 = intParser(a * b)
c2 = intParser((a * x2) + (b * x1))
@@ -35,7 +34,7 @@ def intParser(z):
p1 = p1[1:]
if p3 == "+1":
p3 = ""
- elif p3 == "+":
+ elif p3[0] == "+":
p3 = p3[1:]
if c1 == "+1":
@@ -45,14 +44,9 @@ def intParser(z):
if c2 == "+1":
c2 = ""
- if format == 'string':
- 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
+ problem = f"$({p1}x{p2})({p3}x{p4})$"
+ solution = f"${c1}x^2{c2}x{c3}$"
+ return problem, solution
expanding = Generator(
diff --git a/mathgenerator/funcs/algebra/factoring.py b/mathgenerator/funcs/algebra/factoring.py
index 5f7c57b0..f20404ca 100644
--- a/mathgenerator/funcs/algebra/factoring.py
+++ b/mathgenerator/funcs/algebra/factoring.py
@@ -2,17 +2,18 @@
import random
-def gen_func(range_x1=10, range_x2=10, format='string'):
+def gen_func(range_x1=10, range_x2=10):
+ """Given a quadratic equation in the form x^2 + bx + c, factor it into it's roots (x - x1)(x -x2)"""
x1 = random.randint(-range_x1, range_x1)
x2 = random.randint(-range_x2, range_x2)
def intParser(z):
- if (z == 0):
- return ""
if (z > 0):
- return "+" + str(z)
- if (z < 0):
- return "-" + str(abs(z))
+ return f"+{z}"
+ elif (z < 0):
+ return f"-{abs(z)}"
+ else:
+ return ""
b = intParser(x1 + x2)
c = intParser(x1 * x2)
@@ -24,15 +25,10 @@ def intParser(z):
else:
problem = f"x^2{b}x{c}"
- if format == 'string':
- x1 = intParser(x1)
- x2 = intParser(x2)
- solution = f"(x{x1})(x{x2})"
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return b, c, x1, x2
+ x1 = intParser(x1)
+ x2 = intParser(x2)
+ solution = f"$(x{x1})(x{x2})$"
+ return f"${problem}$", solution
factoring = Generator("Factoring Quadratic", 21, gen_func,
diff --git a/mathgenerator/funcs/algebra/int_matrix_22_determinant.py b/mathgenerator/funcs/algebra/int_matrix_22_determinant.py
index 6da56f5e..ba87364c 100644
--- a/mathgenerator/funcs/algebra/int_matrix_22_determinant.py
+++ b/mathgenerator/funcs/algebra/int_matrix_22_determinant.py
@@ -1,23 +1,20 @@
from ...generator import Generator
+from ...latexBuilder import bmatrix
import random
-def gen_func(maxMatrixVal=100, format='string'):
+def gen_func(maxMatrixVal=100):
a = random.randint(0, maxMatrixVal)
b = random.randint(0, maxMatrixVal)
c = random.randint(0, maxMatrixVal)
d = random.randint(0, maxMatrixVal)
determinant = a * d - b * c
+ lst = [[a, b], [c, d]]
- if 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
+ problem = f"$\\det {bmatrix(lst)}= $"
+ solution = f"${determinant}$"
+ return problem, solution
int_matrix_22_determinant = Generator("Determinant to 2x2 Matrix", 77,
diff --git a/mathgenerator/funcs/algebra/intersection_of_two_lines.py b/mathgenerator/funcs/algebra/intersection_of_two_lines.py
index c1089350..31201694 100644
--- a/mathgenerator/funcs/algebra/intersection_of_two_lines.py
+++ b/mathgenerator/funcs/algebra/intersection_of_two_lines.py
@@ -8,8 +8,7 @@ def gen_func(minM=-10,
minB=-10,
maxB=10,
minDenominator=1,
- maxDenominator=6,
- format='string'):
+ maxDenominator=6):
def generateEquationString(m, b):
"""
Generates an equation given the slope and intercept.
@@ -66,11 +65,10 @@ def fractionToString(x):
b1 = random.randint(minB, maxB)
b2 = random.randint(minB, maxB)
- equation1 = generateEquationString(m1, b1)
- equation2 = generateEquationString(m2, b2)
+ eq1 = generateEquationString(m1, b1)
+ eq2 = generateEquationString(m2, b2)
- problem = "Find the point of intersection of the two lines: "
- problem += f"{equation1} and {equation2}"
+ problem = f"Find the point of intersection of the two lines: ${eq1}$ and ${eq2}$"
m1 = fractions.Fraction(*m1)
m2 = fractions.Fraction(*m2)
@@ -84,14 +82,9 @@ def fractionToString(x):
else:
intersection_x = (b1 - b2) / (m2 - m1)
intersection_y = ((m2 * b1) - (m1 * b2)) / (m2 - m1)
- solution = f"({fractionToString(intersection_x)}, {fractionToString(intersection_y)})"
+ solution = f"$({fractionToString(intersection_x)}, {fractionToString(intersection_y)})$"
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return equation1, equation2, solution
+ return problem, solution
intersection_of_two_lines = Generator(
diff --git a/mathgenerator/funcs/algebra/invert_matrix.py b/mathgenerator/funcs/algebra/invert_matrix.py
index c52f1d5d..4c785eca 100644
--- a/mathgenerator/funcs/algebra/invert_matrix.py
+++ b/mathgenerator/funcs/algebra/invert_matrix.py
@@ -1,4 +1,5 @@
from ...generator import Generator
+from ...latexBuilder import bmatrix
import random
import math
import sympy
@@ -6,8 +7,7 @@
def gen_func(SquareMatrixDimension=3,
MaxMatrixElement=99,
- OnlyIntegerElementsInInvertedMatrix=False,
- format='string'):
+ OnlyIntegerElementsInInvertedMatrix=True):
if OnlyIntegerElementsInInvertedMatrix is True:
isItOk = False
Mat = list()
@@ -77,17 +77,12 @@ def gen_func(SquareMatrixDimension=3,
Mat.append(z)
Mat = sympy.Matrix(Mat)
- if format == 'string':
- 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)
+ problem = 'Inverse of Matrix $' + bmatrix(Mat.tolist()) + '$ is:'
+ solution = bmatrix(sympy.Matrix.inv(Mat).tolist())
+ return problem, solution
invert_matrix = Generator("Inverse of a Matrix", 74, gen_func, [
"SquareMatrixDimension=3", "MaxMatrixElement=99",
- "OnlyIntegerElementsInInvertedMatrix=False"
+ "OnlyIntegerElementsInInvertedMatrix=True"
])
diff --git a/mathgenerator/funcs/algebra/linear_equations.py b/mathgenerator/funcs/algebra/linear_equations.py
index 56f57244..dc008371 100644
--- a/mathgenerator/funcs/algebra/linear_equations.py
+++ b/mathgenerator/funcs/algebra/linear_equations.py
@@ -2,7 +2,7 @@
import random
-def gen_func(n=2, varRange=20, coeffRange=20, format='string'):
+def gen_func(n=2, varRange=20, coeffRange=20):
if n > 10:
print("[!] n cannot be greater than 10")
return None, None
@@ -10,7 +10,7 @@ def gen_func(n=2, varRange=20, coeffRange=20, format='string'):
vars = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g'][:n]
soln = [random.randint(-varRange, varRange) for i in range(n)]
problem = list()
- solution = ", ".join(
+ solution = "$, $".join(
["{} = {}".format(vars[i], soln[i]) for i in range(n)])
for _ in range(n):
@@ -27,14 +27,9 @@ def gen_func(n=2, varRange=20, coeffRange=20, format='string'):
problem.append(prob)
# problem = "\n".join(problem)
- problem = ", ".join(problem)
-
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
+ problem = "$ and $".join(problem)
+
+ return f'Given the equations ${problem}$, solve for $x$ and $y$', f'${solution}$'
linear_equations = Generator("Linear Equations", 26, gen_func,
diff --git a/mathgenerator/funcs/algebra/log.py b/mathgenerator/funcs/algebra/log.py
index b89f7932..7c1f7f6c 100644
--- a/mathgenerator/funcs/algebra/log.py
+++ b/mathgenerator/funcs/algebra/log.py
@@ -7,16 +7,9 @@ def gen_func(maxBase=3, maxVal=8, format='string'):
b = random.randint(2, maxBase)
c = pow(b, a)
- if format == 'string':
- problem = "log" + str(b) + "(" + str(c) + ")"
- solution = str(a)
- return problem, solution
- elif format == 'latex':
- problem = "\\(\\log_{" + str(b) + "}" + str(c) + "\\)"
- solution = "\\(" + str(a) + "\\)"
- return problem, solution
- else:
- return b, c, a
+ problem = f'$log_{{{b}}}({c})=$'
+ solution = f'${a}$'
+ return problem, solution
log = Generator("Logarithm", 12, gen_func, ["maxBase=3", "maxVal=8"])
diff --git a/mathgenerator/funcs/algebra/matrix_multiplication.py b/mathgenerator/funcs/algebra/matrix_multiplication.py
index 0ab50965..1f93d4fc 100644
--- a/mathgenerator/funcs/algebra/matrix_multiplication.py
+++ b/mathgenerator/funcs/algebra/matrix_multiplication.py
@@ -1,62 +1,29 @@
from ...generator import Generator
+from ...latexBuilder import bmatrix
import random
-def gen_func(maxVal=100, max_dim=10, format='string'):
+def gen_func(maxVal=100, max_dim=10):
m = random.randint(2, max_dim)
n = random.randint(2, max_dim)
k = random.randint(2, max_dim)
# generate matrices a and b
- a = []
- for r in range(m):
- a.append([])
- for c in range(n):
- a[r].append(random.randint(-maxVal, maxVal))
- b = []
- for r in range(n):
- b.append([])
- for c in range(k):
- b[r].append(random.randint(-maxVal, maxVal))
+ a = [[random.randint(-maxVal, maxVal) for _ in range(n)] for _ in range(m)]
+ b = [[random.randint(-maxVal, maxVal) for _ in range(k)] for _ in range(n)]
res = []
- a_string = matrixMultiplicationFuncHelper(a)
- b_string = matrixMultiplicationFuncHelper(b)
-
for r in range(m):
res.append([])
-
for c in range(k):
temp = 0
-
for t in range(n):
temp += a[r][t] * b[t][c]
res[r].append(temp)
- # consider using a, b instead of a_string, b_string if the problem doesn't look right
- if 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
-
-
-def matrixMultiplicationFuncHelper(inp):
- m = len(inp)
- n = len(inp[0])
-
- string = "[["
- for i in range(m):
- for j in range(n):
- string += f"{inp[i][j]: 6d}"
- string += ", " if j < n - 1 else ""
- string += "]\n [" if i < m - 1 else ""
- string += "]]"
-
- return string
+ problem = f"Multiply ${bmatrix(a)}$ and ${bmatrix(b)}$"
+ solution = f'${bmatrix(res)}$'
+ return problem, solution
matrix_multiplication = Generator("Multiplication of two matrices", 46,
diff --git a/mathgenerator/funcs/algebra/midpoint_of_two_points.py b/mathgenerator/funcs/algebra/midpoint_of_two_points.py
index b18aa465..95db808e 100644
--- a/mathgenerator/funcs/algebra/midpoint_of_two_points.py
+++ b/mathgenerator/funcs/algebra/midpoint_of_two_points.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxValue=20, format='string'):
+def gen_func(maxValue=20):
x1 = random.randint(-20, maxValue)
y1 = random.randint(-20, maxValue)
x2 = random.randint(-20, maxValue)
@@ -10,14 +10,9 @@ def gen_func(maxValue=20, format='string'):
xm = (x1 + x2) / 2
ym = (y1 + y2) / 2
- if 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
+ problem = f"The midpoint of $({x1},{y1})$ and $({x2},{y2}) = $"
+ solution = f"$({xm},{ym})$"
+ return problem, solution
midpoint_of_two_points = Generator("Midpoint of the two point", 20,
diff --git a/mathgenerator/funcs/algebra/multiply_complex_numbers.py b/mathgenerator/funcs/algebra/multiply_complex_numbers.py
index 93e0dee3..dfc6dc4b 100644
--- a/mathgenerator/funcs/algebra/multiply_complex_numbers.py
+++ b/mathgenerator/funcs/algebra/multiply_complex_numbers.py
@@ -3,22 +3,16 @@
def gen_func(minRealImaginaryNum=-20,
- maxRealImaginaryNum=20,
- format='string'):
+ maxRealImaginaryNum=20):
num1 = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum),
random.randint(minRealImaginaryNum, maxRealImaginaryNum))
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
+ problem = f"${num1} * {num2} = $"
+ solution = f'${product}$'
+ return problem, solution
multiply_complex_numbers = Generator(
diff --git a/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py b/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py
index 9f1a38cc..980b9c4a 100644
--- a/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py
+++ b/mathgenerator/funcs/algebra/multiply_int_to_22_matrix.py
@@ -1,4 +1,5 @@
from ...generator import Generator
+from ...latexBuilder import bmatrix
import random
@@ -14,20 +15,12 @@ def gen_func(maxMatrixVal=10, maxRes=100, format='string'):
b1 = b * constant
c1 = c * constant
d1 = d * constant
+ lst = [[a, b], [c, d]]
+ lst1 = [[a1, b1], [c1, d1]]
- if format == 'string':
- problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = "
- solution = f"[[{a1},{b1}],[{c1},{d1}]]"
- return problem, solution
- elif format == 'latex':
- problem = "\\(" + str(constant) + "\\cdot\\begin{bmatrix}" + str(
- a) + "&" + str(b) + "\\\\" + str(c) + "&" + str(
- d) + "\\end{bmatrix}=\\)"
- solution = "\\(\\begin{bmatrix}" + str(a1) + "&" + str(b1) + \
- "\\\\" + str(c1) + "&" + str(d1) + "\\end{bmatrix}\\)"
- return problem, solution
- else:
- return constant, a, b, c, d, a1, b1, c1, d1
+ problem = f'${constant} * {bmatrix(lst)} =$'
+ solution = f'${bmatrix(lst1)}$'
+ return problem, solution
multiply_int_to_22_matrix = Generator("Integer Multiplication with 2x2 Matrix",
diff --git a/mathgenerator/funcs/algebra/quadratic_equation.py b/mathgenerator/funcs/algebra/quadratic_equation.py
index 16422b06..8f970b89 100644
--- a/mathgenerator/funcs/algebra/quadratic_equation.py
+++ b/mathgenerator/funcs/algebra/quadratic_equation.py
@@ -3,23 +3,17 @@
import math
-def gen_func(maxVal=100, format='string'):
+def gen_func(maxVal=100):
a = random.randint(1, maxVal)
c = random.randint(1, maxVal)
b = random.randint(
round(math.sqrt(4 * a * c)) + 1, round(math.sqrt(4 * maxVal * maxVal)))
D = math.sqrt(b * b - 4 * a * c)
- res = [round((-b + D) / (2 * a), 2), round((-b - D) / (2 * a), 2)]
+ res = {round((-b + D) / (2 * a), 2), round((-b - D) / (2 * a), 2)}
- if format == 'string':
- problem = "Zeros of the Quadratic Equation {}x^2+{}x+{}=0".format(
- a, b, c)
- solution = str(res)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, c, res
+ problem = f"What are the zeros of the quadratic equation ${a}x^2+{b}x+{c}=0$"
+ solution = f'${res}$'
+ return problem, solution
quadratic_equation = Generator("Quadratic Equation", 50, gen_func,
diff --git a/mathgenerator/funcs/algebra/simple_interest.py b/mathgenerator/funcs/algebra/simple_interest.py
index 1b4d3fc7..172bd17f 100644
--- a/mathgenerator/funcs/algebra/simple_interest.py
+++ b/mathgenerator/funcs/algebra/simple_interest.py
@@ -4,24 +4,15 @@
def gen_func(maxPrinciple=10000,
maxRate=10,
- maxTime=10,
- format='string'):
- a = random.randint(1000, maxPrinciple)
- b = random.randint(1, maxRate)
- c = random.randint(1, maxTime)
- d = round((a * b * c) / 100, 2)
+ maxTime=10):
+ p = random.randint(1000, maxPrinciple)
+ r = random.randint(1, maxRate)
+ t = random.randint(1, maxTime)
+ s = round((p * r * t) / 100, 2)
- if format == 'string':
- problem = "Simple interest for a principle amount of " + str(
- a) + " dollars, " + str(
- b) + "% rate of interest and for a time period of " + str(
- c) + " years is = "
- solution = str(d)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, c, d
+ problem = f"Simple interest for a principle amount of ${p}$ dollars, ${r}$% rate of interest and for a time period of ${t}$ years is $=$ "
+ solution = f'${s}$'
+ return problem, solution
simple_interest = Generator("Simple Interest", 45, gen_func,
diff --git a/mathgenerator/funcs/algebra/system_of_equations.py b/mathgenerator/funcs/algebra/system_of_equations.py
index 12bad365..c179b5f6 100644
--- a/mathgenerator/funcs/algebra/system_of_equations.py
+++ b/mathgenerator/funcs/algebra/system_of_equations.py
@@ -45,14 +45,9 @@ def coeffToFuncString(coeffs):
'' if x_str != '' else '0')
return f'{x_str}{op}{y_str} = {coeffs[2]}'
- if format == 'string':
- 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
+ problem = f"Given ${coeffToFuncString(new_c1)}$ and ${coeffToFuncString(new_c2)}$, solve for $x$ and $y$."
+ solution = f"$x = {x}$, $y = {y}$"
+ return problem, solution
# 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 939c25e6..39242411 100644
--- a/mathgenerator/funcs/algebra/vector_cross.py
+++ b/mathgenerator/funcs/algebra/vector_cross.py
@@ -2,22 +2,17 @@
import random
-def gen_func(minVal=-20, maxVal=20, format='string'):
- a = [random.randint(minVal, maxVal) for i in range(3)]
- b = [random.randint(minVal, maxVal) for i in range(3)]
+def gen_func(minVal=-20, maxVal=20):
+ a = [random.randint(minVal, maxVal) for _ in range(3)]
+ b = [random.randint(minVal, maxVal) for _ in range(3)]
c = [
a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2],
a[0] * b[1] - a[1] * b[0]
]
- if 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
+ problem = f"${a} \\times {b} = $"
+ solution = f"${c}$"
+ return problem, solution
vector_cross = Generator("Cross Product of 2 Vectors", 43, gen_func,
diff --git a/mathgenerator/funcs/algebra/vector_dot.py b/mathgenerator/funcs/algebra/vector_dot.py
index 033621e2..26d7de02 100644
--- a/mathgenerator/funcs/algebra/vector_dot.py
+++ b/mathgenerator/funcs/algebra/vector_dot.py
@@ -2,19 +2,14 @@
import random
-def gen_func(minVal=-20, maxVal=20, format='string'):
+def gen_func(minVal=-20, maxVal=20):
a = [random.randint(minVal, maxVal) for i in range(3)]
b = [random.randint(minVal, maxVal) for i in range(3)]
c = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
- if format == 'string':
- problem = str(a) + " . " + str(b) + " = "
- solution = str(c)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, c
+ problem = f'${a}\\cdot{b}=$'
+ solution = f'${c}$'
+ return problem, solution
vector_dot = Generator("Dot Product of 2 Vectors", 72, gen_func,
diff --git a/mathgenerator/funcs/basic_math/absolute_difference.py b/mathgenerator/funcs/basic_math/absolute_difference.py
index 521a64d5..783b8488 100644
--- a/mathgenerator/funcs/basic_math/absolute_difference.py
+++ b/mathgenerator/funcs/basic_math/absolute_difference.py
@@ -2,17 +2,12 @@
import random
-def gen_func(maxA=100, maxB=100, format='string'):
+def gen_func(maxA=100, maxB=100):
a = random.randint(-1 * maxA, maxA)
b = random.randint(-1 * maxB, maxB)
absDiff = abs(a - b)
- if format == "string":
- return "|" + str(a) + "-" + str(b) + "|=", absDiff
- elif format == 'latex':
- return ("\\(|" + str(a) + "-" + str(b) + "|=\\)", f"\\({absDiff}\\)")
- else:
- return a, b, absDiff
+ return f'$|{a}-{b}|=$', f"${absDiff}$"
absolute_difference = Generator("Absolute difference between two numbers", 71,
diff --git a/mathgenerator/funcs/basic_math/addition.py b/mathgenerator/funcs/basic_math/addition.py
index 7152075b..aadc11f5 100644
--- a/mathgenerator/funcs/basic_math/addition.py
+++ b/mathgenerator/funcs/basic_math/addition.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxSum=99, maxAddend=50, format='string'):
+def gen_func(maxSum=99, maxAddend=50):
if maxAddend > maxSum:
maxAddend = maxSum
a = random.randint(0, maxAddend)
@@ -10,16 +10,9 @@ def gen_func(maxSum=99, maxAddend=50, format='string'):
b = random.randint(0, min((maxSum - a), maxAddend))
c = a + b
- if format == "string":
- problem = str(a) + "+" + str(b) + "="
- solution = str(c)
- return problem, solution
- elif format == 'latex':
- problem = "\\(" + str(a) + '+' + str(b) + "\\)"
- solution = str(c)
- return problem, solution
- else:
- return a, b, c
+ problem = f'${a}+{b}=$'
+ solution = f'${c}$'
+ return problem, solution
addition = Generator("Addition", 0, gen_func, ["maxSum=99", "maxAddend=50"])
diff --git a/mathgenerator/funcs/basic_math/compare_fractions.py b/mathgenerator/funcs/basic_math/compare_fractions.py
index 516ba011..9039297c 100644
--- a/mathgenerator/funcs/basic_math/compare_fractions.py
+++ b/mathgenerator/funcs/basic_math/compare_fractions.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxVal=10, format='string'):
+def gen_func(maxVal=10):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
c = random.randint(1, maxVal)
@@ -23,16 +23,8 @@ def gen_func(maxVal=10, format='string'):
else:
solution = "="
- if format == "string":
- return (
- f"Which symbol represents the comparison between {a}/{b} and {c}/{d}?",
- solution)
- elif format == 'latex':
- return (
- f"Which symbol represents the comparison between \\(\\frac{{{a}}}{{{b}}}\\) and \\(\\frac{{{c}}}{{{d}}}\\)?",
- solution)
- else:
- return a, b, c, d, solution
+ problem = f"Which symbol represents the comparison between $\\frac{{{a}}}{{{b}}}$ and $\\frac{{{c}}}{{{d}}}$?"
+ return problem, solution
compare_fractions = Generator("Compare Fractions", 44, gen_func,
diff --git a/mathgenerator/funcs/basic_math/cube_root.py b/mathgenerator/funcs/basic_math/cube_root.py
index 496bc65b..f96290d9 100644
--- a/mathgenerator/funcs/basic_math/cube_root.py
+++ b/mathgenerator/funcs/basic_math/cube_root.py
@@ -2,16 +2,11 @@
import random
-def gen_func(minNo=1, maxNo=1000, format='string'):
+def gen_func(minNo=1, maxNo=1000):
b = random.randint(minNo, maxNo)
a = b**(1 / 3)
- if format == 'string':
- return "What is the cube root of " + str(b) + " up to 2 decimal places?", str(round(a, 2))
- elif format == 'latex':
- return (f"\\(\\sqrt[3]{{{b}}}=\\)", "\\(" + str(round(a, 2)) + "\\)")
- else:
- return b, a
+ return (f"What is the cube root of: $\\sqrt[3]{{{b}}}=$ to 2 decimal places?", f"${round(a, 2)}$")
cube_root = Generator("Cube Root", 47, gen_func, ["minNo=1", "maxNo=1000"])
diff --git a/mathgenerator/funcs/basic_math/divide_fractions.py b/mathgenerator/funcs/basic_math/divide_fractions.py
index 8b48cecb..fe2d6dd9 100644
--- a/mathgenerator/funcs/basic_math/divide_fractions.py
+++ b/mathgenerator/funcs/basic_math/divide_fractions.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxVal=10, format='string'):
+def gen_func(maxVal=10):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
@@ -25,24 +25,8 @@ def calculate_gcd(x, y):
gcd = calculate_gcd(tmp_n, tmp_d)
sol_numerator = tmp_n // gcd
sol_denominator = tmp_d // gcd
- x = f"{sol_numerator}/{sol_denominator}"
-
- if (tmp_d == 1 or tmp_d == gcd):
- x = f"{sol_numerator}"
-
- if format == 'string':
- return f"({a}/{b})/({c}/{d})", x
- elif format == 'latex':
- problem = "\\(\\frac{" + str(a) + "}{" + str(b) + \
- "}\\div\\frac{" + str(c) + "}{" + str(d) + "}=\\)"
- if tmp_d == 1 or tmp_d == gcd:
- solution = "\\(" + str(sol_numerator) + "\\)"
- else:
- solution = "\\(\\frac{" + str(sol_numerator) + \
- "}{" + str(sol_denominator) + "}\\)"
- return problem, solution
- else:
- return a, b, c, d, x
+
+ return f'$\\frac{{{a}}}{{{b}}}\\div\\frac{{{c}}}{{{d}}}=$', f'$\\frac{{{sol_numerator}}}{{{sol_denominator}}}$'
divide_fractions = Generator("Fraction Division", 16, gen_func,
diff --git a/mathgenerator/funcs/basic_math/division.py b/mathgenerator/funcs/basic_math/division.py
index 06aa815a..3f77350d 100644
--- a/mathgenerator/funcs/basic_math/division.py
+++ b/mathgenerator/funcs/basic_math/division.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxA=25, maxB=25, format='string'):
+def gen_func(maxA=25, maxB=25):
a = random.randint(1, maxA)
b = random.randint(1, maxB)
@@ -10,13 +10,7 @@ def gen_func(maxA=25, maxB=25, format='string'):
dividend = random.choice([a, b])
quotient = int(divisor / dividend)
- if format == 'string':
- return f"{divisor}/{dividend}=", str(quotient)
- elif format == 'latex':
- return ("\\(" + str(divisor) + "\\div" + str(dividend) + "=\\)",
- "\\(" + str(quotient) + "\\)")
- else:
- return divisor, dividend, quotient
+ return f'${divisor}\\div{dividend}=$', f'${quotient}$'
division = Generator("Division", 3, gen_func, ["maxA=25", "maxB=25"])
diff --git a/mathgenerator/funcs/basic_math/exponentiation.py b/mathgenerator/funcs/basic_math/exponentiation.py
index fe810597..74129a24 100644
--- a/mathgenerator/funcs/basic_math/exponentiation.py
+++ b/mathgenerator/funcs/basic_math/exponentiation.py
@@ -2,16 +2,11 @@
import random
-def gen_func(maxBase=20, maxExpo=10, format='string'):
+def gen_func(maxBase=20, maxExpo=10):
base = random.randint(1, maxBase)
expo = random.randint(1, maxExpo)
- if format == 'string':
- return (f"{base}^{expo} =", str(base**expo))
- elif format == 'latex':
- return f"\\({base}^{{{expo}}}\\)", "\\(" + str(base**expo) + "\\)"
- else:
- return base, expo, base**expo
+ return f'${base}^{expo} =$', f'${base**expo}$'
exponentiation = Generator("Exponentiation", 53, gen_func,
diff --git a/mathgenerator/funcs/basic_math/factorial.py b/mathgenerator/funcs/basic_math/factorial.py
index 6832a925..d5796672 100644
--- a/mathgenerator/funcs/basic_math/factorial.py
+++ b/mathgenerator/funcs/basic_math/factorial.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxInput=6, format='string'):
+def gen_func(maxInput=6):
a = random.randint(0, maxInput)
n = a
b = 1
@@ -10,12 +10,7 @@ def gen_func(maxInput=6, format='string'):
b *= n
n -= 1
- if format == 'string':
- return str(a) + "! = ", str(b)
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b
+ return f'${a}! =$', f'${b}$'
factorial = Generator("Factorial", 31, gen_func, ["maxInput=6"])
diff --git a/mathgenerator/funcs/basic_math/fraction_multiplication.py b/mathgenerator/funcs/basic_math/fraction_multiplication.py
index a6ac7430..e63bc82e 100644
--- a/mathgenerator/funcs/basic_math/fraction_multiplication.py
+++ b/mathgenerator/funcs/basic_math/fraction_multiplication.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxVal=10, format='string'):
+def gen_func(maxVal=10):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
c = random.randint(1, maxVal)
@@ -23,22 +23,13 @@ def calculate_gcd(x, y):
tmp_d = b * d
gcd = calculate_gcd(tmp_n, tmp_d)
- x = f"{tmp_n//gcd}/{tmp_d//gcd}"
+ problem = f"$\\frac{{{a}}}{{{b}}}\\cdot\\frac{{{c}}}{{{d}}}=$"
if (tmp_d == 1 or tmp_d == gcd):
- x = f"{tmp_n//gcd}"
-
- if format == 'string':
- return f"({a}/{b})*({c}/{d})", x
- elif format == 'latex':
- problem = f"\\(\\frac{{{a}}}{{{b}}}\\cdot\\frac{{{c}}}{{{d}}}=\\)"
- if (tmp_d == 1 or tmp_d == gcd):
- solution = f"\\(\\frac{{{tmp_n}}}{{{gcd}}}\\)"
- else:
- solution = f"\\(\\frac{{{tmp_n//gcd}}}{{{tmp_d//gcd}}}\\)"
- return problem, solution
+ solution = f"$\\frac{{{tmp_n}}}{{{gcd}}}$"
else:
- return a, b, c, d, x
+ solution = f"$\\frac{{{tmp_n//gcd}}}{{{tmp_d//gcd}}}$"
+ return problem, solution
fraction_multiplication = Generator("Fraction Multiplication", 28,
diff --git a/mathgenerator/funcs/basic_math/fraction_to_decimal.py b/mathgenerator/funcs/basic_math/fraction_to_decimal.py
index 214e4b8c..05d4cf3d 100644
--- a/mathgenerator/funcs/basic_math/fraction_to_decimal.py
+++ b/mathgenerator/funcs/basic_math/fraction_to_decimal.py
@@ -2,18 +2,12 @@
import random
-def gen_func(maxRes=99, maxDivid=99, format='string'):
+def gen_func(maxRes=99, maxDivid=99):
a = random.randint(0, maxDivid)
b = random.randint(1, min(maxRes, maxDivid))
c = round(a / b, 2)
- if format == "string":
- return (str(a) + "/" + str(b) + "=", str(c))
- elif format == 'latex':
- return ("\\(" + str(a) + "\\div" + str(b) + "=\\)",
- "\\(" + str(c) + "\\)")
- else:
- return a, b, c
+ return f'${a}\\div{b}=$', f'${c}$'
fraction_to_decimal = Generator("Fraction to Decimal", 13, gen_func,
diff --git a/mathgenerator/funcs/basic_math/greatest_common_divisor.py b/mathgenerator/funcs/basic_math/greatest_common_divisor.py
index 0c8c365e..e7df8e9b 100644
--- a/mathgenerator/funcs/basic_math/greatest_common_divisor.py
+++ b/mathgenerator/funcs/basic_math/greatest_common_divisor.py
@@ -10,7 +10,7 @@ def greatestCommonDivisorOfTwoNumbers(number1, number2):
return number1
-def gen_func(numbersCount=2, maximalNumberLimit=10**9, format='string'):
+def gen_func(numbersCount=2, maximalNumberLimit=10**9):
numbersCount = max(numbersCount, 2)
numbers = [random.randint(0, maximalNumberLimit)
for number in range(numbersCount)]
@@ -22,12 +22,7 @@ def gen_func(numbersCount=2, maximalNumberLimit=10**9, format='string'):
greatestCommonDivisor = greatestCommonDivisorOfTwoNumbers(
numbers[index], greatestCommonDivisor)
- if format == "string":
- return "GCD(" + ",".join(map(str, numbers)) + ")=", str(greatestCommonDivisor)
- elif format == "latex":
- return ("\\(GCD(" + ",".join(map(str, numbers)) + ")=", f"\\({greatestCommonDivisor}\\)")
- else:
- return greatestCommonDivisor
+ return f'$GCD({",".join(map(str, numbers))})=$', f"${greatestCommonDivisor}$"
greatest_common_divisor = Generator("Greatest Common Divisor of N Numbers", 120, gen_func, [
diff --git a/mathgenerator/funcs/basic_math/is_composite.py b/mathgenerator/funcs/basic_math/is_composite.py
index 5c115a8e..d38ae23b 100644
--- a/mathgenerator/funcs/basic_math/is_composite.py
+++ b/mathgenerator/funcs/basic_math/is_composite.py
@@ -2,25 +2,18 @@
import random
-def gen_func(maxNum=250, format='string'):
+def gen_func(maxNum=250):
a = random.randint(2, maxNum)
- problem = f"Is {a} composite?"
+ problem = f"Is ${a}$ composite?"
if a == 0 or a == 1:
- solution = "No"
- return (problem, solution)
+ return problem, "No"
for i in range(2, a):
if a % i == 0:
- solution = "Yes"
- return (problem, solution)
+ return problem, "Yes"
solution = "No"
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, solution
+ return problem, solution
is_composite = Generator('Is Composite', 124, gen_func, ["maxNum=250"])
diff --git a/mathgenerator/funcs/basic_math/is_prime.py b/mathgenerator/funcs/basic_math/is_prime.py
index d35b77fc..d0d839c7 100644
--- a/mathgenerator/funcs/basic_math/is_prime.py
+++ b/mathgenerator/funcs/basic_math/is_prime.py
@@ -2,27 +2,19 @@
import random
-def gen_func(max_num=100, format='string'):
+def gen_func(max_num=100):
a = random.randint(2, max_num)
- problem = f"Is {a} prime?"
+ problem = f"Is ${a}$ prime?"
if a == 2:
- solution = "Yes"
- return (problem, solution)
+ return problem, "Yes"
if a % 2 == 0:
- solution = "No"
- return (problem, solution)
+ return problem, "No"
for i in range(3, a // 2 + 1, 2):
if a % i == 0:
- solution = "No"
- return (problem, solution)
+ return problem, "No"
solution = "Yes"
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, solution
+ return problem, solution
is_prime = Generator('isprime', 90, gen_func, ["max_num=100"])
diff --git a/mathgenerator/funcs/basic_math/multiplication.py b/mathgenerator/funcs/basic_math/multiplication.py
index 3f262916..e3054ec1 100644
--- a/mathgenerator/funcs/basic_math/multiplication.py
+++ b/mathgenerator/funcs/basic_math/multiplication.py
@@ -2,20 +2,12 @@
import random
-def gen_func(maxMulti=12, format='string'):
+def gen_func(maxMulti=12):
a = random.randint(0, maxMulti)
b = random.randint(0, maxMulti)
c = a * b
- if format == 'string':
- problem = str(a) + "*" + str(b) + "="
- solution = str(c)
- return problem, solution
- elif format == 'latex':
- problem = "\\(" + str(a) + "\\cdot" + str(b) + "=\\)"
- solution = "\\(" + str(c) + "\\)"
- else:
- return a, b, c
+ return f'${a}\\cdot{b}$', f'${c}$'
multiplication = Generator("Multiplication", 2, gen_func,
diff --git a/mathgenerator/funcs/basic_math/percentage.py b/mathgenerator/funcs/basic_math/percentage.py
index 9ca475a0..4702bec5 100644
--- a/mathgenerator/funcs/basic_math/percentage.py
+++ b/mathgenerator/funcs/basic_math/percentage.py
@@ -2,20 +2,15 @@
import random
-def gen_func(maxValue=99, maxpercentage=99, format='string'):
+def gen_func(maxValue=99, maxpercentage=99):
a = random.randint(1, maxpercentage)
b = random.randint(1, maxValue)
- problem = f"What is {a}% of {b}?"
+ problem = f"What is ${a}$% of ${b}$?"
percentage = a / 100 * b
formatted_float = "{:.2f}".format(percentage)
- solution = f"{formatted_float}"
+ solution = f"${formatted_float}$"
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, formatted_float
+ return problem, solution
percentage = Generator("Percentage of a number", 80, gen_func,
diff --git a/mathgenerator/funcs/basic_math/percentage_difference.py b/mathgenerator/funcs/basic_math/percentage_difference.py
index 8b2f403d..8433da2a 100644
--- a/mathgenerator/funcs/basic_math/percentage_difference.py
+++ b/mathgenerator/funcs/basic_math/percentage_difference.py
@@ -2,23 +2,16 @@
import random
-def gen_func(maxValue=200, minValue=0, format='string'):
+def gen_func(maxValue=200, minValue=0):
value_a = random.randint(minValue, maxValue)
value_b = random.randint(minValue, maxValue)
diff = 2 * (abs(value_a - value_b) / abs(value_a + value_b)) * 100
diff = round(diff, 2)
- if format == 'string':
- problem = f"What is the percentage difference between {value_a} and {value_b}?"
- solution = str(diff) + "%"
- return problem, solution
-
- elif format == 'latex':
- return 'Latex unavailable'
-
- else:
- return value_a, value_b, diff
+ problem = f"What is the percentage difference between ${value_a}$ and ${value_b}$?"
+ solution = f'${diff}$%'
+ return problem, solution
percentage_difference = Generator("Percentage difference", 118, gen_func,
diff --git a/mathgenerator/funcs/basic_math/percentage_error.py b/mathgenerator/funcs/basic_math/percentage_error.py
index fe579cab..7e0e2064 100644
--- a/mathgenerator/funcs/basic_math/percentage_error.py
+++ b/mathgenerator/funcs/basic_math/percentage_error.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxValue=100, minValue=-100, format='string'):
+def gen_func(maxValue=100, minValue=-100):
observed_value = random.randint(minValue, maxValue)
exact_value = random.randint(minValue, maxValue)
@@ -12,16 +12,9 @@ def gen_func(maxValue=100, minValue=-100, format='string'):
error = (abs(observed_value - exact_value) / abs(exact_value)) * 100
error = round(error, 2)
- if format == 'string':
- problem = f"Find the percentage error when observed value equals {observed_value} and exact value equals {exact_value}."
- solution = str(error) + "%"
- return problem, solution
-
- elif format == 'latex':
- return 'Latex unavailable'
-
- else:
- return observed_value, exact_value, error
+ problem = f"Find the percentage error when observed value equals ${observed_value}$ and exact value equals ${exact_value}$."
+ solution = f'${error}\\%$'
+ return problem, solution
percentage_error = Generator(
diff --git a/mathgenerator/funcs/basic_math/power_of_powers.py b/mathgenerator/funcs/basic_math/power_of_powers.py
index 20d1e578..43989d73 100644
--- a/mathgenerator/funcs/basic_math/power_of_powers.py
+++ b/mathgenerator/funcs/basic_math/power_of_powers.py
@@ -2,23 +2,15 @@
import random
-def gen_func(maxBase=50, maxPower=10, format='string'):
+def gen_func(maxBase=50, maxPower=10):
base = random.randint(1, maxBase)
power1 = random.randint(1, maxPower)
power2 = random.randint(1, maxPower)
step = power1 * power2
- if format == 'string':
- problem = f"Simplify {base}^{power1}^{power2}="
- solution = str(base) + '^' + str(step)
- return problem, solution
- elif format == 'latex':
- problem = "Simplify \\(" + str(base) + \
- "^{" + str(power1) + "^{" + str(power2) + "}}\\)"
- solution = f"\\({base}^{{{step}}}\\)"
- return problem, solution
- else:
- return base, power1, power2, base, step
+ problem = f"Simplify ${base}^{{{power1}^{{{power2}}}}}$"
+ solution = f"${base}^{{{step}}}$"
+ return problem, solution
power_of_powers = Generator("Power of Powers", 97, gen_func,
diff --git a/mathgenerator/funcs/basic_math/square.py b/mathgenerator/funcs/basic_math/square.py
index d8ebc8f5..73519fc1 100644
--- a/mathgenerator/funcs/basic_math/square.py
+++ b/mathgenerator/funcs/basic_math/square.py
@@ -2,20 +2,11 @@
import random
-def gen_func(maxSquareNum=20, format='string'):
+def gen_func(maxSquareNum=20):
a = random.randint(1, maxSquareNum)
- b = a * a
+ b = a ** 2
- if format == 'string':
- problem = str(a) + "^2" + "="
- solution = str(b)
- return problem, solution
- if format == 'latex':
- problem = "\\(" + str(a) + "^{2}=\\)"
- solution = "\\(" + str(b) + "\\)"
- return problem, solution
- else:
- return a, b
+ return f'${a}^2=$', f'${b}$'
square = Generator("Square", 8, gen_func, ["maxSquareNum=20"])
diff --git a/mathgenerator/funcs/basic_math/square_root.py b/mathgenerator/funcs/basic_math/square_root.py
index 09389efb..2ee782f2 100644
--- a/mathgenerator/funcs/basic_math/square_root.py
+++ b/mathgenerator/funcs/basic_math/square_root.py
@@ -2,20 +2,11 @@
import random
-def gen_func(minNo=1, maxNo=12, format='string'):
+def gen_func(minNo=1, maxNo=12):
b = random.randint(minNo, maxNo)
- a = b * b
+ a = b ** 2
- if format == 'string':
- problem = "sqrt(" + str(a) + ")="
- solution = str(b)
- return problem, solution
- elif format == 'latex':
- problem = "\\(\\sqrt{" + str(a) + "}=\\)"
- solution = "\\(" + str(b) + "\\)"
- return problem, solution
- else:
- return a, b
+ return f'$\\sqrt{{{a}}}=$', f'${b}$'
square_root = Generator("Square Root", 6, gen_func,
diff --git a/mathgenerator/funcs/basic_math/subtraction.py b/mathgenerator/funcs/basic_math/subtraction.py
index 11b99151..4ec82923 100644
--- a/mathgenerator/funcs/basic_math/subtraction.py
+++ b/mathgenerator/funcs/basic_math/subtraction.py
@@ -2,19 +2,12 @@
import random
-def gen_func(maxMinuend=99, maxDiff=99, format='string'):
+def gen_func(maxMinuend=99, maxDiff=99):
a = random.randint(0, maxMinuend)
b = random.randint(max(0, (a - maxDiff)), a)
c = a - b
- if format == 'string':
- problem = str(a) + "-" + str(b) + "="
- solution = str(c)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, c
+ return f'${a}-{b}=$', f'${c}$'
subtraction = Generator("Subtraction", 1, gen_func,
diff --git a/mathgenerator/funcs/calculus/__init__.py b/mathgenerator/funcs/calculus/__init__.py
index abb977dc..2f30f161 100644
--- a/mathgenerator/funcs/calculus/__init__.py
+++ b/mathgenerator/funcs/calculus/__init__.py
@@ -1,5 +1,5 @@
from .definite_integral import definite_integral
-from .differentiation import differentiation
from .power_rule_differentiation import power_rule_differentiation
from .power_rule_integration import power_rule_integration
from .stationary_points import stationary_points
+from .trig_differentiation import trig_differentiation
diff --git a/mathgenerator/funcs/calculus/definite_integral.py b/mathgenerator/funcs/calculus/definite_integral.py
index 4aec425b..94f8ee9b 100644
--- a/mathgenerator/funcs/calculus/definite_integral.py
+++ b/mathgenerator/funcs/calculus/definite_integral.py
@@ -3,7 +3,7 @@
from scipy.integrate import quad
-def gen_func(max_coeff=100, format='string'):
+def gen_func(max_coeff=100):
def integrand(x, a, b, c):
return a * x**2 + b * x + c
@@ -14,15 +14,9 @@ def integrand(x, a, b, c):
result = quad(integrand, 0, 1, args=(a, b, c))[0]
S = round(result, 4)
- if format == 'string':
- problem = "The definite integral within limits 0 to 1 of the equation " + \
- 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
+ problem = f"The definite integral within limits $0$ to $1$ of the equation ${a}x^2 + {b}x + {c} = $"
+ solution = f'${S}$'
+ return problem, solution
definite_integral = Generator("Definite Integral of Quadratic Equation", 89,
diff --git a/mathgenerator/funcs/calculus/differentiation.py b/mathgenerator/funcs/calculus/differentiation.py
deleted file mode 100644
index 2e9311ad..00000000
--- a/mathgenerator/funcs/calculus/differentiation.py
+++ /dev/null
@@ -1,59 +0,0 @@
-from ...generator import Generator
-import random
-import sympy
-
-
-def genDifferentiationProblem(diff_lvl=2):
- problem = ''
-
- types = {
- 'Logrithmic': ['ln'],
- 'Trigonometric': ['sin', 'cos', 'tan', 'cot', 'sec'],
- 'Exponentional': ['exp']
- }
-
- if diff_lvl == 1:
- coeff = random.randrange(2, 10)
- power = random.randint(2, 4)
- flag = random.random()
- if flag > 0.5:
- power *= -1
- problem += str(coeff) + '*x^' + '(' + str(power) + ')'
- else:
- problem += str(coeff) + '*x^' + str(power)
- if diff_lvl == 2:
- func_type = random.choices(list(types.keys()), weights=(1, 4, 1))[0]
- func = random.choice(types[func_type])
- problem += func + '(x)' + '+' + genDifferentiationProblem(1)
- if diff_lvl == 3:
- func_type = random.choices(list(types.keys()), weights=(1, 4, 1))[0]
- func = random.choice(types[func_type])
- problem += func + '(' + genDifferentiationProblem(1) + ')'
- if diff_lvl == 4:
- operator = random.choice(('/', '*'))
- problem = '(' + genDifferentiationProblem(2) + ')' + \
- operator + '(' + genDifferentiationProblem(3) + ')'
- return problem
-
-
-def gen_func(diff_lvl=2, format='string'):
- if diff_lvl < 1 or diff_lvl > 4:
- print("diff_lvl not supported")
- return None
- problem = genDifferentiationProblem(diff_lvl)
-
- x = sympy.symbols('x')
- solution = str(sympy.diff(problem.replace('^', '**'), x))
- solution = solution.replace('**', '^')
- problem = f"differentiate w.r.t x : d({problem})/dx"
-
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
-
-
-differentiation = Generator("Differentiation", 88, gen_func,
- ["diff_lvl=2"])
diff --git a/mathgenerator/funcs/calculus/power_rule_differentiation.py b/mathgenerator/funcs/calculus/power_rule_differentiation.py
index 5fc5fad0..de5615ee 100644
--- a/mathgenerator/funcs/calculus/power_rule_differentiation.py
+++ b/mathgenerator/funcs/calculus/power_rule_differentiation.py
@@ -4,11 +4,10 @@
def gen_func(maxCoef=10,
maxExp=10,
- maxTerms=5,
- format='string'):
+ maxTerms=5):
numTerms = random.randint(1, maxTerms)
- problem = ""
- solution = ""
+ problem = "$"
+ solution = "$"
for i in range(numTerms):
if i > 0:
@@ -17,15 +16,10 @@ def gen_func(maxCoef=10,
coefficient = random.randint(1, maxCoef)
exponent = random.randint(1, maxExp)
- problem += str(coefficient) + "x^" + str(exponent)
- solution += str(coefficient * exponent) + "x^" + str(exponent - 1)
+ problem += f'{coefficient}x^{{{exponent}}}'
+ solution += f'{coefficient * exponent}x^{{{exponent - 1}}}'
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
+ return problem + '$', solution + '$'
power_rule_differentiation = Generator(
diff --git a/mathgenerator/funcs/calculus/power_rule_integration.py b/mathgenerator/funcs/calculus/power_rule_integration.py
index 6b8a9c9e..948eaa0d 100644
--- a/mathgenerator/funcs/calculus/power_rule_integration.py
+++ b/mathgenerator/funcs/calculus/power_rule_integration.py
@@ -4,11 +4,10 @@
def gen_func(maxCoef=10,
maxExp=10,
- maxTerms=5,
- format='string'):
+ maxTerms=5):
numTerms = random.randint(1, maxTerms)
- problem = ""
- solution = ""
+ problem = "$"
+ solution = "$"
for i in range(numTerms):
if i > 0:
@@ -17,18 +16,12 @@ def gen_func(maxCoef=10,
coefficient = random.randint(1, maxCoef)
exponent = random.randint(1, maxExp)
- problem += str(coefficient) + "x^" + str(exponent)
- solution += "(" + str(coefficient) + "/" + \
- str(exponent) + ")x^" + str(exponent + 1)
+ problem += f'{coefficient}x^{{{exponent}}}'
+ solution += f'\\frac{{{coefficient}}}{{{exponent}}}x^{{{exponent + 1}}}'
- solution += " + c"
+ solution += " + C"
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
+ return problem + '$', solution + '$'
power_rule_integration = Generator("Power Rule Integration", 48,
diff --git a/mathgenerator/funcs/calculus/stationary_points.py b/mathgenerator/funcs/calculus/stationary_points.py
index 697a54d6..dccf7795 100644
--- a/mathgenerator/funcs/calculus/stationary_points.py
+++ b/mathgenerator/funcs/calculus/stationary_points.py
@@ -3,8 +3,9 @@
import sympy
-def gen_func(maxExp=3, maxCoef=10, format='string'):
- while True:
+def gen_func(maxExp=3, maxCoef=10):
+ solution = ''
+ while len(solution) == 0:
x = sympy.symbols('x')
problem = 0
for exp in range(maxExp + 1):
@@ -12,17 +13,8 @@ def gen_func(maxExp=3, maxCoef=10, format='string'):
problem += coefficient * pow(x, exp)
solution = sympy.stationary_points(problem, x)
- # if len(solution) != 0:
- solution = ','.join(
- '({},{})'.format(str(p), sympy.sympify(problem.replace(x, p)))
- for p in solution)
- problem = 'f(x)=' + str(problem).replace('**', '^')
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
+ problem = 'f(x)=' + str(problem).replace('**', '^')
+ return f'${problem}$', f'${sympy.latex(solution)[6:-8]}}}$'
stationary_points = Generator("Stationary Points", 110, gen_func,
diff --git a/mathgenerator/funcs/calculus/trig_differentiation.py b/mathgenerator/funcs/calculus/trig_differentiation.py
new file mode 100644
index 00000000..1464b747
--- /dev/null
+++ b/mathgenerator/funcs/calculus/trig_differentiation.py
@@ -0,0 +1,22 @@
+from ...generator import Generator
+import random
+
+
+def gen_func():
+ pairs = {
+ '\\sin': '\\cos',
+ '\\cos': '-\\sin',
+ '\\tan': '\\sec^{{2}}',
+ '\\cot': '-\\csc^{{2}}',
+ '\\sec': '\\sec \\cdot \\tan',
+ '\\csc': '-\\csc \\cdot \\cot'
+ }
+ problem = random.choice(list(pairs.keys()))
+ solution = f'${pairs[problem]}$'
+ problem = f'$\\frac{{d}}{{dx}}({problem})=$'
+
+ return problem, solution
+
+
+trig_differentiation = Generator("Trigonometric Differentiation", 88, gen_func,
+ [])
diff --git a/mathgenerator/funcs/computer_science/bcd_to_decimal.py b/mathgenerator/funcs/computer_science/bcd_to_decimal.py
index e2578450..316cdeff 100644
--- a/mathgenerator/funcs/computer_science/bcd_to_decimal.py
+++ b/mathgenerator/funcs/computer_science/bcd_to_decimal.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxNumber=10000, format='string'):
+def gen_func(maxNumber=10000):
n = random.randint(1000, maxNumber)
binstring = ''
while True:
@@ -16,14 +16,9 @@ def gen_func(maxNumber=10000, format='string'):
else:
n = q
- if 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)
+ problem = f"Integer of Binary Coded Decimal ${n}$ is $=$ "
+ solution = f'${int(binstring, 2)}$'
+ return problem, solution
bcd_to_decimal = Generator("Binary Coded Decimal to Integer", 91,
diff --git a/mathgenerator/funcs/computer_science/binary_2s_complement.py b/mathgenerator/funcs/computer_science/binary_2s_complement.py
index 7cd444b7..a66b0baa 100644
--- a/mathgenerator/funcs/computer_science/binary_2s_complement.py
+++ b/mathgenerator/funcs/computer_science/binary_2s_complement.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxDigits=10, format='string'):
+def gen_func(maxDigits=10):
digits = random.randint(1, maxDigits)
question = ''.join([str(random.randint(0, 1))
for i in range(digits)]).lstrip('0')
@@ -24,14 +24,9 @@ def gen_func(maxDigits=10, format='string'):
if j == 0 and carry is True:
answer.insert(0, '1')
- if 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
+ problem = f"2's complement of ${question} = $"
+ solution = ''.join(answer).lstrip('0')
+ return problem, f'${solution}$'
binary_2s_complement = Generator("Binary 2's Complement", 73,
diff --git a/mathgenerator/funcs/computer_science/binary_complement_1s.py b/mathgenerator/funcs/computer_science/binary_complement_1s.py
index 91ea0bee..2badb806 100644
--- a/mathgenerator/funcs/computer_science/binary_complement_1s.py
+++ b/mathgenerator/funcs/computer_science/binary_complement_1s.py
@@ -2,22 +2,17 @@
import random
-def gen_func(maxDigits=10, format='string'):
+def gen_func(maxDigits=10):
question = ''
answer = ''
- for i in range(random.randint(1, maxDigits)):
+ for _ in range(random.randint(1, maxDigits)):
temp = str(random.randint(0, 1))
question += temp
answer += "0" if temp == "1" else "1"
- if format == 'string':
- problem = question + "="
- return problem, answer
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, answer
+ problem = f'${question} = $'
+ return problem, f'${answer}$'
binary_complement_1s = Generator("Binary Complement 1s", 4,
diff --git a/mathgenerator/funcs/computer_science/binary_to_decimal.py b/mathgenerator/funcs/computer_science/binary_to_decimal.py
index 71aca1e5..d03d977c 100644
--- a/mathgenerator/funcs/computer_science/binary_to_decimal.py
+++ b/mathgenerator/funcs/computer_science/binary_to_decimal.py
@@ -2,20 +2,15 @@
import random
-def gen_func(max_dig=10, format='string'):
+def gen_func(max_dig=10):
problem = ''
- for i in range(random.randint(1, max_dig)):
+ for _ in range(random.randint(1, max_dig)):
temp = str(random.randint(0, 1))
problem += temp
- if format == 'string':
- solution = int(problem, 2)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
+ solution = f'${int(problem, 2)}$'
+ return f'${problem}$', solution
binary_to_decimal = Generator("Binary to Decimal", 15, gen_func,
diff --git a/mathgenerator/funcs/computer_science/binary_to_hex.py b/mathgenerator/funcs/computer_science/binary_to_hex.py
index 3538c868..8d70a3da 100644
--- a/mathgenerator/funcs/computer_science/binary_to_hex.py
+++ b/mathgenerator/funcs/computer_science/binary_to_hex.py
@@ -2,19 +2,14 @@
import random
-def gen_func(max_dig=10, format='string'):
+def gen_func(max_dig=10):
problem = ''
- for i in range(random.randint(1, max_dig)):
+ for _ in range(random.randint(1, max_dig)):
temp = str(random.randint(0, 1))
problem += temp
- if format == 'string':
- solution = hex(int(problem, 2))
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return problem, solution
+ solution = f'${hex(int(problem, 2))}$'
+ return f'${problem}$', solution
binary_to_hex = Generator("Binary to Hexidecimal", 64, gen_func,
diff --git a/mathgenerator/funcs/computer_science/decimal_to_bcd.py b/mathgenerator/funcs/computer_science/decimal_to_bcd.py
index abaa7b9b..1d78c0b3 100644
--- a/mathgenerator/funcs/computer_science/decimal_to_bcd.py
+++ b/mathgenerator/funcs/computer_science/decimal_to_bcd.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxNumber=10000, format='string'):
+def gen_func(maxNumber=10000):
n = random.randint(1000, maxNumber)
x = n
# binstring = ''
@@ -12,14 +12,8 @@ def gen_func(maxNumber=10000, format='string'):
bcdstring = str(nibble) + bcdstring
x >>= 4
- 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)
+ problem = f"BCD of Decimal Number ${n} = $"
+ return problem, f'${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 49ae9b20..280659ae 100644
--- a/mathgenerator/funcs/computer_science/decimal_to_binary.py
+++ b/mathgenerator/funcs/computer_science/decimal_to_binary.py
@@ -2,18 +2,13 @@
import random
-def gen_func(max_dec=99, format='string'):
+def gen_func(max_dec=99):
a = random.randint(1, max_dec)
b = bin(a).replace("0b", "")
- 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)
+ problem = f'Binary of ${a} = $'
+ solution = f'${b}$'
+ return problem, solution
decimal_to_binary = Generator("Decimal to Binary", 14, gen_func,
diff --git a/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py b/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py
index 44c41fb9..73295858 100644
--- a/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py
+++ b/mathgenerator/funcs/computer_science/decimal_to_hexadeci.py
@@ -2,18 +2,13 @@
import random
-def gen_func(max_dec=1000, format='string'):
+def gen_func(max_dec=1000):
a = random.randint(0, max_dec)
b = hex(a)
- 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)
+ problem = f"Binary of ${a} = $"
+ solution = f"${b}$"
+ return problem, solution
decimal_to_hexadeci = Generator("Decimal to Hexadecimal", 79, gen_func,
diff --git a/mathgenerator/funcs/computer_science/decimal_to_octal.py b/mathgenerator/funcs/computer_science/decimal_to_octal.py
index b19f0644..9fe1be6e 100644
--- a/mathgenerator/funcs/computer_science/decimal_to_octal.py
+++ b/mathgenerator/funcs/computer_science/decimal_to_octal.py
@@ -2,17 +2,13 @@
import random
-def gen_func(maxDecimal=4096, format='string'):
+def gen_func(maxDecimal=4096):
x = random.randint(0, maxDecimal)
- problem = "The decimal number " + str(x) + " in Octal is: "
- solution = oct(x)
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return x, oct(x)
+ problem = "The decimal number ${x}$ in Octal is: "
+ solution = f'${oct(x)}$'
+
+ return problem, solution
decimal_to_octal = Generator("Converts decimal to octal", 84,
diff --git a/mathgenerator/funcs/computer_science/fibonacci_series.py b/mathgenerator/funcs/computer_science/fibonacci_series.py
index ec218407..7592f4bd 100644
--- a/mathgenerator/funcs/computer_science/fibonacci_series.py
+++ b/mathgenerator/funcs/computer_science/fibonacci_series.py
@@ -2,7 +2,7 @@
import random
-def gen_func(minNo=1, format='string'):
+def gen_func(minNo=1):
n = random.randint(minNo, 20)
def createFibList(n):
@@ -17,14 +17,9 @@ def createFibList(n):
fibList = createFibList(n)
- if 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
+ problem = "The Fibonacci Series of the first ${n}$ numbers is ?"
+ solution = ', '.join(map(str, fibList))
+ return problem, f'${solution}$'
fibonacci_series = Generator("Fibonacci Series", 56, gen_func,
diff --git a/mathgenerator/funcs/computer_science/modulo_division.py b/mathgenerator/funcs/computer_science/modulo_division.py
index 6843966c..ebb1acba 100644
--- a/mathgenerator/funcs/computer_science/modulo_division.py
+++ b/mathgenerator/funcs/computer_science/modulo_division.py
@@ -2,19 +2,14 @@
import random
-def gen_func(maxRes=99, maxModulo=99, format='string'):
+def gen_func(maxRes=99, maxModulo=99):
a = random.randint(0, maxModulo)
b = random.randint(0, min(maxRes, maxModulo))
c = a % b if b != 0 else 0
- if format == 'string':
- problem = str(a) + "%" + str(b) + "="
- solution = str(c)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, c
+ problem = f'${a}$ % ${b} = $'
+ solution = f'${c}$'
+ return problem, solution
modulo_division = Generator("Modulo Division", 5, gen_func,
diff --git a/mathgenerator/funcs/computer_science/nth_fibonacci_number.py b/mathgenerator/funcs/computer_science/nth_fibonacci_number.py
index d9cb6feb..5876fc93 100644
--- a/mathgenerator/funcs/computer_science/nth_fibonacci_number.py
+++ b/mathgenerator/funcs/computer_science/nth_fibonacci_number.py
@@ -3,18 +3,14 @@
import math
-def gen_func(maxN=100, format='string'):
+def gen_func(maxN=100):
gratio = (1 + math.sqrt(5)) / 2
n = random.randint(1, maxN)
+
problem = f"What is the {n}th Fibonacci number?"
- ans = int((math.pow(gratio, n) - math.pow(-gratio, -n)) / (math.sqrt(5)))
+ solution = int((math.pow(gratio, n) - math.pow(-gratio, -n)) / (math.sqrt(5)))
- if format == 'string':
- return problem, str(ans)
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return n, ans
+ return problem, f'${solution}$'
nth_fibonacci_number = Generator("nth Fibonacci number", 62,
diff --git a/mathgenerator/funcs/geometry/angle_btw_vectors.py b/mathgenerator/funcs/geometry/angle_btw_vectors.py
index 777963dd..bf7a8896 100644
--- a/mathgenerator/funcs/geometry/angle_btw_vectors.py
+++ b/mathgenerator/funcs/geometry/angle_btw_vectors.py
@@ -3,7 +3,7 @@
import math
-def gen_func(maxEltAmt=20, format='string'):
+def gen_func(maxEltAmt=20):
s = 0
v1 = [
round(random.uniform(0, 1000), 2)
@@ -19,19 +19,14 @@ def gen_func(maxEltAmt=20, format='string'):
ans = 0
try:
ans = round(math.acos(s / mags), 2)
- solution = str(ans) + " radians"
+ solution = f"${ans}$ radians"
except ValueError:
print('angleBtwVectorsFunc has some issues with math module, line 16')
solution = 'NaN'
ans = 'NaN'
# would return the answer in radians
- 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
+ problem = f"angle between the vectors ${v1}$ and ${v2}$ is:"
+ return problem, solution
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 894aecfd..2cb245b9 100644
--- a/mathgenerator/funcs/geometry/angle_regular_polygon.py
+++ b/mathgenerator/funcs/geometry/angle_regular_polygon.py
@@ -4,17 +4,12 @@
def gen_func(minVal=3, maxVal=20, format='string'):
sideNum = random.randint(minVal, maxVal)
- problem = f"Find the angle of a regular polygon with {sideNum} sides"
+ problem = f"Find the angle of a regular polygon with ${sideNum}$ sides"
exteriorAngle = round((360 / sideNum), 2)
- solution = 180 - exteriorAngle
+ solution = f'${180 - exteriorAngle}$'
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return sideNum, solution
+ return problem, solution
angle_regular_polygon = Generator("Angle of a Regular Polygon", 29,
diff --git a/mathgenerator/funcs/geometry/arc_length.py b/mathgenerator/funcs/geometry/arc_length.py
index 1d511edc..d94afb47 100644
--- a/mathgenerator/funcs/geometry/arc_length.py
+++ b/mathgenerator/funcs/geometry/arc_length.py
@@ -3,20 +3,15 @@
import math
-def gen_func(maxRadius=49, maxAngle=359, format='string'):
+def gen_func(maxRadius=49, maxAngle=359):
radius = random.randint(1, maxRadius)
angle = random.randint(1, maxAngle)
- problem = f"Given radius, {radius} and angle, {angle}. Find the arc length of the angle."
angle_arc_length = float((angle / 360) * 2 * math.pi * radius)
formatted_float = "{:.5f}".format(angle_arc_length)
- 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
+ problem = f"Given radius, ${radius}$ and angle, ${angle}$. Find the arc length of the angle."
+ solution = f"Arc length of the angle $= {formatted_float}$"
+ return problem, solution
arc_length = Generator("Arc length of Angle", 108, gen_func,
diff --git a/mathgenerator/funcs/geometry/area_of_circle.py b/mathgenerator/funcs/geometry/area_of_circle.py
index d5308ab7..b11d1d22 100644
--- a/mathgenerator/funcs/geometry/area_of_circle.py
+++ b/mathgenerator/funcs/geometry/area_of_circle.py
@@ -1,19 +1,14 @@
from ...generator import Generator
import random
+from math import pi
-def gen_func(maxRadius=100, format='string'):
+def gen_func(maxRadius=100):
r = random.randint(0, maxRadius)
- pi = 22 / 7
- area = pi * r * r
+ area = round(pi * r * r, 2)
- 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
+ problem = f'Area of circle with radius ${r}=$'
+ return problem, f'${area}$'
area_of_circle = Generator("Area of Circle", 112, gen_func,
diff --git a/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py b/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py
index 46169d77..f736eb09 100644
--- a/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py
+++ b/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py
@@ -3,7 +3,7 @@
from math import cos, sin, pi
-def gen_func(maxCoordinate=10, maxRadius=10, format='string'):
+def gen_func(maxCoordinate=10, maxRadius=10):
r = random.randint(0, maxRadius)
center_x = random.randint(-maxCoordinate, maxCoordinate)
center_y = random.randint(-maxCoordinate, maxCoordinate)
@@ -15,13 +15,8 @@ def gen_func(maxCoordinate=10, maxRadius=10, format='string'):
area = round(pi * r * r, 2)
- if format == 'string':
- problem = f"Area of circle with center ({center_x},{center_y}) and passing through ({point_x}, {point_y}) is"
- return problem, str(area)
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return center_x, center_y, point_x, point_y, area
+ problem = f"Area of circle with center $({center_x},{center_y})$ and passing through $({point_x}, {point_y})$ is"
+ return problem, f'${area}$'
area_of_circle_given_center_and_point = Generator("Area of Circle given center and a point on circle", 115, gen_func,
diff --git a/mathgenerator/funcs/geometry/area_of_triangle.py b/mathgenerator/funcs/geometry/area_of_triangle.py
index f6f086f0..13ca5e20 100644
--- a/mathgenerator/funcs/geometry/area_of_triangle.py
+++ b/mathgenerator/funcs/geometry/area_of_triangle.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxA=20, maxB=20, format='string'):
+def gen_func(maxA=20, maxB=20):
a = random.randint(1, maxA)
b = random.randint(1, maxB)
c = random.randint(abs(b - a) + 1, abs(a + b) - 1)
@@ -10,15 +10,9 @@ def gen_func(maxA=20, maxB=20, format='string'):
s = (a + b + c) / 2
area = (s * (s - a) * (s - b) * (s - c))**0.5
- if format == 'string':
- problem = "Area of triangle with side lengths: " + \
- str(a) + " " + str(b) + " " + str(c) + " = "
- solution = str(round(area, 2))
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, c, area
+ problem = f"Area of triangle with side lengths: ${a}, {b} {c} = $"
+ solution = f'${round(area, 2)}$'
+ return problem, solution
area_of_triangle = Generator("Area of Triangle", 18, gen_func,
diff --git a/mathgenerator/funcs/geometry/basic_trigonometry.py b/mathgenerator/funcs/geometry/basic_trigonometry.py
index 68600a07..647ea22e 100644
--- a/mathgenerator/funcs/geometry/basic_trigonometry.py
+++ b/mathgenerator/funcs/geometry/basic_trigonometry.py
@@ -5,33 +5,27 @@
# Handles degrees in quadrant one
def gen_func(angles=[0, 30, 45, 60, 90],
- functions=["sin", "cos", "tan"],
- format='string'):
+ functions=["sin", "cos", "tan"]):
angle = random.choice(angles)
function = random.choice(functions)
- problem = f"What is {function}({angle})?"
+ problem = f"$\\{function}({angle}) = $"
expression = 'math.' + function + '(math.radians(angle))'
result_fraction_map = {
0.0: "0",
- 0.5: "1/2",
- 0.71: "1/√2",
- 0.87: "√3/2",
+ 0.5: "\\frac{1}{2}",
+ 0.71: "\\frac{1}{\\sqrt{2}}",
+ 0.87: "\\frac{\\sqrt{3}}{2}",
1.0: "1",
- 0.58: "1/√3",
- 1.73: "√3"
+ 0.58: "\\frac{1}{\\sqrt{3}}",
+ 1.73: "\\sqrt{3}",
}
solution = result_fraction_map[round(eval(expression), 2)] if round(
- eval(expression), 2) <= 99999 else "∞" # for handling the ∞ condition
-
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return function, angle, solution
+ eval(expression), 2) <= 99999 else "\\infty" # for handling the ∞ condition
+
+ return problem, f'${solution}$'
basic_trigonometry = Generator(
diff --git a/mathgenerator/funcs/geometry/circumference.py b/mathgenerator/funcs/geometry/circumference.py
index b433ad38..850a6000 100644
--- a/mathgenerator/funcs/geometry/circumference.py
+++ b/mathgenerator/funcs/geometry/circumference.py
@@ -3,17 +3,12 @@
import math
-def gen_func(maxRadius=100, format='string'):
+def gen_func(maxRadius=100):
r = random.randint(0, maxRadius)
- circumference = 2 * math.pi * r
+ circumference = round(2 * math.pi * r, 2)
- if format == 'string':
- problem = f"Circumference of circle with radius {r}"
- return problem, circumference
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return r, circumference
+ problem = f"Circumference of circle with radius ${r} = $"
+ return problem, f'${circumference}$'
circumference = Generator("Circumference", 104, gen_func,
diff --git a/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py b/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py
index 067ecb2d..a56f0e06 100644
--- a/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py
+++ b/mathgenerator/funcs/geometry/curved_surface_area_cylinder.py
@@ -3,20 +3,15 @@
import math
-def gen_func(maxRadius=49, maxHeight=99, format='string'):
+def gen_func(maxRadius=49, maxHeight=99):
r = random.randint(1, maxRadius)
h = random.randint(1, maxHeight)
csa = float(2 * math.pi * r * h)
formatted_float = round(csa, 2) # "{:.5f}".format(csa)
- if 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
+ problem = f"What is the curved surface area of a cylinder of radius, ${r}$ and height, ${h}$?"
+ solution = f"${formatted_float}$"
+ return problem, solution
curved_surface_area_cylinder = Generator("Curved surface area of a cylinder",
diff --git a/mathgenerator/funcs/geometry/degree_to_rad.py b/mathgenerator/funcs/geometry/degree_to_rad.py
index ed87ec5a..905accc4 100644
--- a/mathgenerator/funcs/geometry/degree_to_rad.py
+++ b/mathgenerator/funcs/geometry/degree_to_rad.py
@@ -3,19 +3,14 @@
import math
-def gen_func(max_deg=360, format='string'):
+def gen_func(max_deg=360):
a = random.randint(0, max_deg)
b = (math.pi * a) / 180
b = round(b, 2)
- if 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
+ problem = f"Angle ${a}$ degrees in radians is: "
+ solution = f'${b}$'
+ return problem, solution
degree_to_rad = Generator("Degrees to Radians", 86, gen_func,
diff --git a/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py b/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py
index a72cb8f9..5eaf9a27 100644
--- a/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py
+++ b/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py
@@ -3,13 +3,7 @@
import math
-def gen_func(maxCoordinate=20, minCoordinate=-20, format='string'):
- def greatest_common_divisor(num1, num2):
- if num2 == 0:
- return num1
- else:
- return math.gcd(num2, num1 % num2)
-
+def gen_func(maxCoordinate=20, minCoordinate=-20):
x1 = random.randint(minCoordinate, maxCoordinate)
x2 = random.randint(minCoordinate, maxCoordinate)
@@ -49,22 +43,18 @@ def greatest_common_divisor(num1, num2):
coeff_y = ''
else:
coeff_y = '-'
- if format == 'string':
- problem = f"What is the equation of the line between points ({x1},{y1}) and ({x2},{y2}) in slope-intercept form?"
- if coeff_x == 0:
- solution = str(coeff_y) + "y = " + str(constant)
- elif coeff_y == 0:
- solution = str(coeff_x) + "x = " + str(-constant)
- else:
- if constant > 0:
- solution = str(coeff_y) + "y = " + str(coeff_x) + "x + " + str(constant)
- else:
- solution = str(coeff_y) + "y = " + str(coeff_x) + "x " + str(constant)
- return problem, solution
- elif format == 'latex':
- return 'Latex unavailable'
+
+ problem = f"What is the equation of the line between points $({x1},{y1})$ and $({x2},{y2})$ in slope-intercept form?"
+ if coeff_x == 0:
+ solution = str(coeff_y) + "y = " + str(constant)
+ elif coeff_y == 0:
+ solution = str(coeff_x) + "x = " + str(-constant)
else:
- return x1, x2, y1, y2, coeff_x, coeff_y, constant
+ if constant > 0:
+ solution = str(coeff_y) + "y = " + str(coeff_x) + "x + " + str(constant)
+ else:
+ solution = str(coeff_y) + "y = " + str(coeff_x) + "x " + str(constant)
+ return problem, f'${solution}$'
equation_of_line_from_two_points = Generator(
diff --git a/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py b/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py
index 8fef2495..af484710 100644
--- a/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py
+++ b/mathgenerator/funcs/geometry/fourth_angle_of_quadrilateral.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxAngle=180, format='string'):
+def gen_func(maxAngle=180):
angle1 = random.randint(1, maxAngle)
angle2 = random.randint(1, 240 - angle1)
angle3 = random.randint(1, 340 - (angle1 + angle2))
@@ -10,14 +10,9 @@ def gen_func(maxAngle=180, format='string'):
sum_ = angle1 + angle2 + angle3
angle4 = 360 - sum_
- if 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
+ problem = f"Fourth angle of quadrilateral with angles ${angle1} , {angle2}, {angle3} =$"
+ solution = f'${angle4}$'
+ return problem, solution
fourth_angle_of_quadrilateral = Generator("Fourth Angle of Quadrilateral", 49,
diff --git a/mathgenerator/funcs/geometry/perimeter_of_polygons.py b/mathgenerator/funcs/geometry/perimeter_of_polygons.py
index b40063d7..69c520a0 100644
--- a/mathgenerator/funcs/geometry/perimeter_of_polygons.py
+++ b/mathgenerator/funcs/geometry/perimeter_of_polygons.py
@@ -2,23 +2,14 @@
import random
-def gen_func(maxSides=12, maxLength=120, format='string'):
+def gen_func(maxSides=12, maxLength=120):
size_of_sides = random.randint(3, maxSides)
- sides = []
- for x in range(size_of_sides):
- sides.append(random.randint(1, maxLength))
- problem = "The perimeter of a " + str(size_of_sides) + \
- " sided polygon with lengths of " + str(sides) + "cm is: "
- solution = 0
- for y in range(len(sides)):
- solution += sides[y]
+ sides = [random.randint(1, maxLength) for _ in range(size_of_sides)]
- if format == 'string':
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return size_of_sides, sides, solution
+ problem = f"The perimeter of a ${size_of_sides}$ sided polygon with lengths of ${', '.join(map(str, sides))}$cm is: "
+ solution = sum(sides)
+
+ return problem, f'${solution}$'
perimeter_of_polygons = Generator("Perimeter of Polygons", 96,
diff --git a/mathgenerator/funcs/geometry/pythagorean_theorem.py b/mathgenerator/funcs/geometry/pythagorean_theorem.py
index 88a48489..b54327a6 100644
--- a/mathgenerator/funcs/geometry/pythagorean_theorem.py
+++ b/mathgenerator/funcs/geometry/pythagorean_theorem.py
@@ -2,19 +2,14 @@
import random
-def gen_func(maxLength=20, format='string'):
+def gen_func(maxLength=20):
a = random.randint(1, maxLength)
b = random.randint(1, maxLength)
- c = (a**2 + b**2)**0.5
+ c = round((a ** 2 + b ** 2) ** 0.5, 2)
- if 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)
+ problem = f"What is the hypotenuse of a right triangle given the other two sides have lengths ${a}$ and ${b}$?"
+ solution = f"${c}$"
+ return problem, solution
pythagorean_theorem = Generator("Pythagorean Theorem", 25,
diff --git a/mathgenerator/funcs/geometry/radian_to_deg.py b/mathgenerator/funcs/geometry/radian_to_deg.py
index b70e83dc..8db9f6e3 100644
--- a/mathgenerator/funcs/geometry/radian_to_deg.py
+++ b/mathgenerator/funcs/geometry/radian_to_deg.py
@@ -3,21 +3,14 @@
import math
-def gen_func(max_rad=3, format='string'):
- # max_rad is supposed to be pi but random can't handle non-integer
- a = random.randint(0, max_rad)
- b = (180 * a) / math.pi
- b = round(b, 2)
+def gen_func(max_rad=6.28):
+ a = random.randint(0, int(max_rad * 100)) / 100
+ b = round((180 * a) / math.pi, 2)
- if 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
+ problem = f"Angle ${a}$ radians in degrees is: "
+ solution = f'${b}$'
+ return problem, solution
radian_to_deg = Generator("Radians to Degrees", 87, gen_func,
- ["max_rad=3"])
+ ["max_rad=6.28"])
diff --git a/mathgenerator/funcs/geometry/sector_area.py b/mathgenerator/funcs/geometry/sector_area.py
index bbc1b433..d9af3ef4 100644
--- a/mathgenerator/funcs/geometry/sector_area.py
+++ b/mathgenerator/funcs/geometry/sector_area.py
@@ -3,20 +3,15 @@
import math
-def gen_func(maxRadius=49, maxAngle=359, format='string'):
+def gen_func(maxRadius=49, maxAngle=359):
r = random.randint(1, maxRadius)
a = random.randint(1, maxAngle)
secArea = float((a / 360) * math.pi * r * r)
- formatted_float = "{:.5f}".format(secArea)
+ formatted_float = round(secArea, 2)
- if 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
+ problem = f"What is the area of a sector with radius ${r}$ and angle ${a}$ degrees?"
+ solution = f"${formatted_float}$"
+ return problem, solution
sector_area = Generator("Area of a Sector", 75, gen_func,
diff --git a/mathgenerator/funcs/geometry/sum_of_polygon_angles.py b/mathgenerator/funcs/geometry/sum_of_polygon_angles.py
index 96cc0c90..f1bd2bb9 100644
--- a/mathgenerator/funcs/geometry/sum_of_polygon_angles.py
+++ b/mathgenerator/funcs/geometry/sum_of_polygon_angles.py
@@ -2,17 +2,12 @@
import random
-def gen_func(maxSides=12, format='string'):
+def gen_func(maxSides=12):
side_count = random.randint(3, maxSides)
sum = (side_count - 2) * 180
- 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
+ problem = f"What is the sum of interior angles of a polygon with ${side_count}$ sides?"
+ return problem, f'${sum}$'
sum_of_polygon_angles = Generator("Sum of Angles of Polygon", 58,
diff --git a/mathgenerator/funcs/geometry/surface_area_cone.py b/mathgenerator/funcs/geometry/surface_area_cone.py
index 00dc106b..63237d38 100644
--- a/mathgenerator/funcs/geometry/surface_area_cone.py
+++ b/mathgenerator/funcs/geometry/surface_area_cone.py
@@ -3,21 +3,16 @@
import math
-def gen_func(maxRadius=20, maxHeight=50, unit='m', format='string'):
+def gen_func(maxRadius=20, maxHeight=50, unit='m'):
a = random.randint(1, maxHeight)
b = random.randint(1, maxRadius)
slopingHeight = math.sqrt(a**2 + b**2)
ans = int(math.pi * b * slopingHeight + math.pi * b * b)
- if 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
+ problem = f"Surface area of cone with height $= {a}{unit}$ and radius $= {b}{unit}$ is"
+ solution = f"${ans} {unit}^2$"
+ return problem, solution
surface_area_cone = Generator("Surface Area of cone", 38, gen_func,
diff --git a/mathgenerator/funcs/geometry/surface_area_cube.py b/mathgenerator/funcs/geometry/surface_area_cube.py
index 9e6711a1..646f5d3c 100644
--- a/mathgenerator/funcs/geometry/surface_area_cube.py
+++ b/mathgenerator/funcs/geometry/surface_area_cube.py
@@ -2,18 +2,13 @@
import random
-def gen_func(maxSide=20, unit='m', format='string'):
+def gen_func(maxSide=20, unit='m'):
a = random.randint(1, maxSide)
- ans = 6 * a * a
+ ans = 6 * (a ** 2)
- if 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
+ problem = f"Surface area of cube with side $= {a}{unit}$ is"
+ solution = f"${ans} {unit}^2$"
+ return problem, solution
surface_area_cube = Generator("Surface Area of Cube", 32, gen_func,
diff --git a/mathgenerator/funcs/geometry/surface_area_cuboid.py b/mathgenerator/funcs/geometry/surface_area_cuboid.py
index 2dd94b1b..ac22070c 100644
--- a/mathgenerator/funcs/geometry/surface_area_cuboid.py
+++ b/mathgenerator/funcs/geometry/surface_area_cuboid.py
@@ -2,20 +2,15 @@
import random
-def gen_func(maxSide=20, unit='m', format='string'):
+def gen_func(maxSide=20, unit='m'):
a = random.randint(1, maxSide)
b = random.randint(1, maxSide)
c = random.randint(1, maxSide)
ans = 2 * (a * b + b * c + c * a)
- if 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
+ problem = f"Surface area of cuboid with sides of lengths: ${a}{unit}, {b}{unit}, {c}{unit}$ is"
+ solution = f"${ans} {unit}^2$"
+ return problem, solution
surface_area_cuboid = Generator("Surface Area of Cuboid", 33,
diff --git a/mathgenerator/funcs/geometry/surface_area_cylinder.py b/mathgenerator/funcs/geometry/surface_area_cylinder.py
index db99de24..d169c279 100644
--- a/mathgenerator/funcs/geometry/surface_area_cylinder.py
+++ b/mathgenerator/funcs/geometry/surface_area_cylinder.py
@@ -3,19 +3,14 @@
import math
-def gen_func(maxRadius=20, maxHeight=50, unit='m', format='string'):
+def gen_func(maxRadius=20, maxHeight=50, unit='m'):
a = random.randint(1, maxHeight)
b = random.randint(1, maxRadius)
ans = int(2 * math.pi * a * b + 2 * math.pi * b * b)
- if 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
+ problem = f"Surface area of cylinder with height $= {a}{unit}$ and radius $= {b}{unit}$ is"
+ solution = f"${ans} {unit}^2$"
+ return problem, solution
surface_area_cylinder = Generator("Surface Area of Cylinder", 34,
diff --git a/mathgenerator/funcs/geometry/surface_area_pyramid.py b/mathgenerator/funcs/geometry/surface_area_pyramid.py
index d4c983da..c2f74e44 100644
--- a/mathgenerator/funcs/geometry/surface_area_pyramid.py
+++ b/mathgenerator/funcs/geometry/surface_area_pyramid.py
@@ -14,7 +14,7 @@
(7, 24, 25)]
-def gen_func(unit='m', format='string'):
+def gen_func(unit='m'):
# Generate first triplet
height, half_width, triangle_height_1 = random.sample(random.choice(_PYTHAGOREAN), 3)
@@ -33,14 +33,9 @@ def gen_func(unit='m', format='string'):
ans = base + 2 * triangle_1 + 2 * triangle_2
- if format == 'string':
- problem = f"Surface area of pyramid with base length = {2*half_length}{unit}, base width = {2*half_width}{unit}, and height = {height}{unit}"
- solution = f"{ans} {unit}^2"
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return 2 * half_length, 2 * half_width, height, ans, unit
+ problem = f"Surface area of pyramid with base length $= {2*half_length}{unit}$, base width $= {2*half_width}{unit}$, and height $= {height}{unit}$ is"
+ solution = f"${ans} {unit}^2$"
+ return problem, solution
surface_area_pyramid = Generator("Surface area of pyramid", 123, gen_func,
diff --git a/mathgenerator/funcs/geometry/surface_area_sphere.py b/mathgenerator/funcs/geometry/surface_area_sphere.py
index 8f2aef0d..58a8d250 100644
--- a/mathgenerator/funcs/geometry/surface_area_sphere.py
+++ b/mathgenerator/funcs/geometry/surface_area_sphere.py
@@ -3,18 +3,13 @@
import math
-def gen_func(maxSide=20, unit='m', format='string'):
+def gen_func(maxSide=20, unit='m'):
r = random.randint(1, maxSide)
ans = 4 * math.pi * r * r
- if 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
+ problem = f"Surface area of Sphere with radius $= {r}{unit}$ is"
+ solution = f"${ans} {unit}^2$"
+ return problem, solution
surface_area_sphere = Generator("Surface Area of Sphere", 60,
diff --git a/mathgenerator/funcs/geometry/third_angle_of_triangle.py b/mathgenerator/funcs/geometry/third_angle_of_triangle.py
index 452c20d1..b63b240f 100644
--- a/mathgenerator/funcs/geometry/third_angle_of_triangle.py
+++ b/mathgenerator/funcs/geometry/third_angle_of_triangle.py
@@ -2,18 +2,13 @@
import random
-def gen_func(maxAngle=89, format='string'):
+def gen_func(maxAngle=89):
angle1 = random.randint(1, maxAngle)
angle2 = random.randint(1, maxAngle)
angle3 = 180 - (angle1 + angle2)
- 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
+ problem = f"Third angle of triangle with angles ${angle1}$ and ${angle2} = $"
+ return problem, f'${angle3}$'
third_angle_of_triangle = Generator("Third Angle of Triangle", 22,
diff --git a/mathgenerator/funcs/geometry/valid_triangle.py b/mathgenerator/funcs/geometry/valid_triangle.py
index ea5f503a..6f5ecb06 100644
--- a/mathgenerator/funcs/geometry/valid_triangle.py
+++ b/mathgenerator/funcs/geometry/valid_triangle.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxSideLength=50, format='string'):
+def gen_func(maxSideLength=50):
sideA = random.randint(1, maxSideLength)
sideB = random.randint(1, maxSideLength)
sideC = random.randint(1, maxSideLength)
@@ -13,17 +13,9 @@ def gen_func(maxSideLength=50, format='string'):
exists = True & (sides[0] < sideSums[0]) & (sides[1] < sideSums[1]) & (
sides[2] < sideSums[2])
- if format == 'string':
- problem = f"Does triangle with sides {sideA}, {sideB} and {sideC} exist?"
- if exists:
- solution = "Yes"
- else:
- solution = "No"
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return sideA, sideB, sideC, exists
+ problem = f"Does triangle with sides ${sideA}, {sideB}$ and ${sideC}$ exist?"
+ solution = "Yes" if exists else "No"
+ return problem, f'${solution}$'
valid_triangle = Generator("Triangle exists check", 19, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_cone.py b/mathgenerator/funcs/geometry/volume_cone.py
index 8175cf0e..2b94fdb4 100644
--- a/mathgenerator/funcs/geometry/volume_cone.py
+++ b/mathgenerator/funcs/geometry/volume_cone.py
@@ -3,19 +3,14 @@
import math
-def gen_func(maxRadius=20, maxHeight=50, unit='m', format='string'):
+def gen_func(maxRadius=20, maxHeight=50, unit='m'):
a = random.randint(1, maxHeight)
b = random.randint(1, maxRadius)
ans = int(math.pi * b * b * a * (1 / 3))
- if 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
+ problem = f"Volume of cone with height $= {a}{unit}$ and radius $= {b}{unit}$ is"
+ solution = f"${ans} {unit}^3$"
+ return problem, solution
volume_cone = Generator("Volume of cone", 39, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_cube.py b/mathgenerator/funcs/geometry/volume_cube.py
index acca1d19..aab57b54 100644
--- a/mathgenerator/funcs/geometry/volume_cube.py
+++ b/mathgenerator/funcs/geometry/volume_cube.py
@@ -2,18 +2,13 @@
import random
-def gen_func(maxSide=20, unit='m', format='string'):
+def gen_func(maxSide=20, unit='m'):
a = random.randint(1, maxSide)
ans = a**3
- if 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
+ problem = f"Volume of cube with a side length of ${a}{unit}$ is"
+ solution = f"${ans} {unit}^3$"
+ return problem, solution
volume_cube = Generator("Volume of Cube", 35, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_cuboid.py b/mathgenerator/funcs/geometry/volume_cuboid.py
index 808ec315..157b9527 100644
--- a/mathgenerator/funcs/geometry/volume_cuboid.py
+++ b/mathgenerator/funcs/geometry/volume_cuboid.py
@@ -2,20 +2,15 @@
import random
-def gen_func(maxSide=20, unit='m', format='string'):
+def gen_func(maxSide=20, unit='m'):
a = random.randint(1, maxSide)
b = random.randint(1, maxSide)
c = random.randint(1, maxSide)
ans = a * b * c
- if 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
+ problem = f"Volume of cuboid with sides = ${a}{unit}, {b}{unit}, {c}{unit}$ is"
+ solution = f"${ans} {unit}^3$"
+ return problem, solution
volume_cuboid = Generator("Volume of Cuboid", 36, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_cylinder.py b/mathgenerator/funcs/geometry/volume_cylinder.py
index 549886b7..88fd6123 100644
--- a/mathgenerator/funcs/geometry/volume_cylinder.py
+++ b/mathgenerator/funcs/geometry/volume_cylinder.py
@@ -3,19 +3,14 @@
import math
-def gen_func(maxRadius=20, maxHeight=50, unit='m', format='string'):
+def gen_func(maxRadius=20, maxHeight=50, unit='m'):
a = random.randint(1, maxHeight)
b = random.randint(1, maxRadius)
ans = int(math.pi * b * b * a)
- if 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
+ problem = f"Volume of cylinder with height $= {a}{unit}$ and radius $= {b}{unit}$ is"
+ solution = f"${ans} {unit}^3$"
+ return problem, solution
volume_cylinder = Generator("Volume of cylinder", 37, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_frustum.py b/mathgenerator/funcs/geometry/volume_frustum.py
index 0676c5d9..07c87f79 100644
--- a/mathgenerator/funcs/geometry/volume_frustum.py
+++ b/mathgenerator/funcs/geometry/volume_frustum.py
@@ -3,20 +3,15 @@
import math
-def gen_func(maxR1=20, maxR2=20, maxHeight=50, unit='m', format='string'):
+def gen_func(maxR1=20, maxR2=20, maxHeight=50, unit='m'):
h = random.randint(1, maxHeight)
r1 = random.randint(1, maxR1)
r2 = random.randint(1, maxR2)
ans = ((math.pi * h) * (r1 ** 2 + r2 ** 2 + r1 * r2)) // 3
- if format == 'string':
- problem = f"Volume of frustum with height = {h}{unit} and r1 = {r1}{unit} is and r2 = {r1}{unit} is "
- solution = f"{ans} {unit}^3"
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return r1, r2, h, ans, unit
+ problem = f"Volume of frustum with height $= {h}{unit}$ and $r1 = {r1}{unit}$ is and $r2 = {r1}{unit}$ is "
+ solution = f"${ans} {unit}^3$"
+ return problem, solution
volume_frustum = Generator("Volume of frustum", 113, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_hemisphere.py b/mathgenerator/funcs/geometry/volume_hemisphere.py
index 5425f9ff..5db9a7e3 100644
--- a/mathgenerator/funcs/geometry/volume_hemisphere.py
+++ b/mathgenerator/funcs/geometry/volume_hemisphere.py
@@ -3,18 +3,13 @@
import math
-def gen_func(maxRadius=100, format='string'):
+def gen_func(maxRadius=100):
r = random.randint(1, maxRadius)
ans = round((2 * math.pi / 3) * r**3, 3)
- if format == 'string':
- problem = f"Volume of hemisphere with radius {r} m = "
- solution = f"{ans} m^3"
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return r, ans
+ problem = f"Volume of hemisphere with radius ${r} m =$ "
+ solution = f"${ans} m^3$"
+ return problem, solution
volume_hemisphere = Generator("Volume of Hemisphere", 117, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_pyramid.py b/mathgenerator/funcs/geometry/volume_pyramid.py
index e82220e9..2a119da8 100644
--- a/mathgenerator/funcs/geometry/volume_pyramid.py
+++ b/mathgenerator/funcs/geometry/volume_pyramid.py
@@ -2,21 +2,16 @@
import random
-def gen_func(maxLength=20, maxWidth=20, maxHeight=50, unit='m', format='string'):
+def gen_func(maxLength=20, maxWidth=20, maxHeight=50, unit='m'):
length = random.randint(1, maxLength)
width = random.randint(1, maxWidth)
height = random.randint(1, maxHeight)
ans = (length * width * height) / 3
- if format == 'string':
- problem = f"Volume of pyramid with base length = {length} {unit}, base width = {width} {unit} and height = {height} {unit} is"
- solution = f"{ans} {unit}^3"
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return length, width, height, ans, unit
+ problem = f"Volume of pyramid with base length $= {length} {unit}$, base width $= {width} {unit}$ and height $= {height} {unit}$ is"
+ solution = f"${ans} {unit}^3$"
+ return problem, solution
volume_pyramid = Generator("Volume of pyramid", 122, gen_func,
diff --git a/mathgenerator/funcs/geometry/volume_sphere.py b/mathgenerator/funcs/geometry/volume_sphere.py
index 38818709..689425c6 100644
--- a/mathgenerator/funcs/geometry/volume_sphere.py
+++ b/mathgenerator/funcs/geometry/volume_sphere.py
@@ -3,18 +3,13 @@
import math
-def gen_func(maxRadius=100, format='string'):
+def gen_func(maxRadius=100):
r = random.randint(1, maxRadius)
ans = (4 * math.pi / 3) * r**3
- if 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
+ problem = f"Volume of sphere with radius ${r} m = $"
+ solution = f"${ans} m^3$"
+ return problem, solution
volume_sphere = Generator("Volume of Sphere", 61, gen_func,
diff --git a/mathgenerator/funcs/misc/arithmetic_progression_sum.py b/mathgenerator/funcs/misc/arithmetic_progression_sum.py
index df12a0f9..cd0e9dca 100644
--- a/mathgenerator/funcs/misc/arithmetic_progression_sum.py
+++ b/mathgenerator/funcs/misc/arithmetic_progression_sum.py
@@ -4,8 +4,7 @@
def gen_func(maxd=100,
maxa=100,
- maxn=100,
- format='string'):
+ maxn=100):
d = random.randint(-1 * maxd, maxd)
a1 = random.randint(-1 * maxa, maxa)
a2 = a1 + d
@@ -15,14 +14,8 @@ def gen_func(maxd=100,
an = a1 + (n - 1) * d
solution = n * (a1 + an) / 2
- if format == 'string':
- 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
+ problem = f'Find the sum of first ${n}$ terms of the AP series: ${apString}$'
+ return problem, f'${solution}$'
arithmetic_progression_sum = Generator("AP Sum Calculation", 83,
diff --git a/mathgenerator/funcs/misc/arithmetic_progression_term.py b/mathgenerator/funcs/misc/arithmetic_progression_term.py
index c7e1bb10..a9dc8e17 100644
--- a/mathgenerator/funcs/misc/arithmetic_progression_term.py
+++ b/mathgenerator/funcs/misc/arithmetic_progression_term.py
@@ -4,8 +4,7 @@
def gen_func(maxd=100,
maxa=100,
- maxn=100,
- format='string'):
+ maxn=100):
d = random.randint(-1 * maxd, maxd)
a1 = random.randint(-1 * maxa, maxa)
a2 = a1 + d
@@ -14,14 +13,8 @@ def gen_func(maxd=100,
apString = str(a1) + ', ' + str(a2) + ', ' + str(a3) + ' ... '
solution = a1 + ((n - 1) * d)
- if format == 'string':
- 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
+ problem = f'Find term number ${n}$ of the AP series: ${apString}$'
+ return problem, f'${solution}$'
arithmetic_progression_term = Generator("AP Term Calculation", 82,
diff --git a/mathgenerator/funcs/misc/base_conversion.py b/mathgenerator/funcs/misc/base_conversion.py
index 047e0002..b64b4a6b 100644
--- a/mathgenerator/funcs/misc/base_conversion.py
+++ b/mathgenerator/funcs/misc/base_conversion.py
@@ -32,7 +32,7 @@ def fromBaseTenTo(n, toBase):
# return int(n,fromBase)
-def gen_func(maxNum=60000, maxBase=16, format='string'):
+def gen_func(maxNum=60000, maxBase=16):
assert type(
maxNum
) == int and maxNum >= 100 and maxNum <= 65536, "maxNum({}) must be >=100 and <=65536".format(
@@ -49,16 +49,9 @@ def gen_func(maxNum=60000, maxBase=16, format='string'):
while bases[0] == bases[1]:
bases = random.choices(dist, k=2)
- if format == 'string':
- problem = "Convert {} from base {} to base {}.".format(
- 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])
+ problem = f"Convert ${fromBaseTenTo(n, bases[0])}$ from base ${bases[0]}$ to base ${bases[1]}$."
+ ans = fromBaseTenTo(n, bases[1])
+ return problem, f'${ans}$'
base_conversion = Generator("Base Conversion", 94, gen_func,
diff --git a/mathgenerator/funcs/misc/binomial_distribution.py b/mathgenerator/funcs/misc/binomial_distribution.py
index b54fc436..02bd0795 100644
--- a/mathgenerator/funcs/misc/binomial_distribution.py
+++ b/mathgenerator/funcs/misc/binomial_distribution.py
@@ -3,7 +3,6 @@
def factorial(n):
-
if n == 1 or n == 0:
return 1
else:
@@ -14,7 +13,7 @@ def newton_symbol(n, k):
return factorial(n) / (factorial(k) * factorial(n - k))
-def gen_func(format='string'):
+def gen_func():
rejected_fraction = float(random.randint(30, 40)) + random.random()
batch = random.randint(10, 20)
rejections = random.randint(1, 9)
@@ -27,17 +26,12 @@ def gen_func(format='string'):
answer = round(100 * answer, 2)
- if format == 'string':
- problem = "A manufacturer of metal pistons finds that, on average, {0:}% "\
- "of the pistons they manufacture are rejected because " \
- "they are incorrectly sized. What is the probability that a "\
- "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
+ problem = "A manufacturer of metal pistons finds that, on average, ${0:}$% "\
+ "of the pistons they manufacture are rejected because " \
+ "they are incorrectly sized. What is the probability that a "\
+ "batch of ${1:}$ pistons will contain no more than ${2:}$ " \
+ "rejected pistons?".format(rejected_fraction, batch, rejections)
+ return problem, f'${answer}$'
binomial_distribution = Generator("Binomial distribution", 109,
diff --git a/mathgenerator/funcs/misc/celsius_to_fahrenheit.py b/mathgenerator/funcs/misc/celsius_to_fahrenheit.py
index b2fd2628..a6ce24aa 100644
--- a/mathgenerator/funcs/misc/celsius_to_fahrenheit.py
+++ b/mathgenerator/funcs/misc/celsius_to_fahrenheit.py
@@ -2,19 +2,13 @@
import random
-def gen_func(maxTemp=100, format='string'):
+def gen_func(maxTemp=100):
celsius = random.randint(-50, maxTemp)
fahrenheit = (celsius * (9 / 5)) + 32
- if format == 'string':
- problem = "Convert " + str(
- celsius) + " degrees Celsius to degrees Fahrenheit ="
- solution = str(fahrenheit)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return celsius, fahrenheit
+ problem = f"Convert ${celsius}$ degrees Celsius to degrees Fahrenheit"
+ solution = f'${fahrenheit}$'
+ return problem, solution
celsius_to_fahrenheit = Generator("Celsius To Fahrenheit", 81,
diff --git a/mathgenerator/funcs/misc/common_factors.py b/mathgenerator/funcs/misc/common_factors.py
index e1863a97..e842754d 100644
--- a/mathgenerator/funcs/misc/common_factors.py
+++ b/mathgenerator/funcs/misc/common_factors.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxVal=100, format='string'):
+def gen_func(maxVal=100):
a = x = random.randint(1, maxVal)
b = y = random.randint(1, maxVal)
@@ -20,14 +20,9 @@ def gen_func(maxVal=100, format='string'):
count = count + 1
arr.append(i)
- if 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
+ problem = f"Common Factors of ${a}$ and ${b} = $"
+ solution = f'${arr}$'
+ return problem, solution
common_factors = Generator("Common Factors", 40, gen_func,
diff --git a/mathgenerator/funcs/misc/complex_to_polar.py b/mathgenerator/funcs/misc/complex_to_polar.py
index 71d55130..cdf7f7f7 100644
--- a/mathgenerator/funcs/misc/complex_to_polar.py
+++ b/mathgenerator/funcs/misc/complex_to_polar.py
@@ -4,8 +4,7 @@
def gen_func(minRealImaginaryNum=-20,
- maxRealImaginaryNum=20,
- format='string'):
+ maxRealImaginaryNum=20):
num = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum),
random.randint(minRealImaginaryNum, maxRealImaginaryNum))
a = num.real
@@ -13,13 +12,8 @@ def gen_func(minRealImaginaryNum=-20,
r = round(math.hypot(a, b), 2)
theta = round(math.atan2(b, a), 2)
- 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
+ problem = f'${r}({a}\\theta + i{b}\\theta)$'
+ return problem, f'${theta}$'
complex_to_polar = Generator(
diff --git a/mathgenerator/funcs/misc/decimal_to_roman_numerals.py b/mathgenerator/funcs/misc/decimal_to_roman_numerals.py
index 8c044af6..d507ab52 100644
--- a/mathgenerator/funcs/misc/decimal_to_roman_numerals.py
+++ b/mathgenerator/funcs/misc/decimal_to_roman_numerals.py
@@ -3,7 +3,7 @@
import math
-def gen_func(maxDecimal=4000, format='string'):
+def gen_func(maxDecimal=4000):
x = random.randint(0, maxDecimal)
roman_dict = {
1: "I",
@@ -32,13 +32,8 @@ def gen_func(maxDecimal=4000, format='string'):
x = math.floor(x % div)
div /= 10
- 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
+ problem = f"The number ${x}$ in Roman Numerals is: "
+ return problem, f'${solution}$'
decimal_to_roman_numerals = Generator("Converts decimal to Roman Numerals", 85,
diff --git a/mathgenerator/funcs/misc/euclidian_norm.py b/mathgenerator/funcs/misc/euclidian_norm.py
index 84c9011b..cf04db4a 100644
--- a/mathgenerator/funcs/misc/euclidian_norm.py
+++ b/mathgenerator/funcs/misc/euclidian_norm.py
@@ -3,19 +3,14 @@
import math
-def gen_func(maxEltAmt=20, format='string'):
+def gen_func(maxEltAmt=20):
vec = [
random.uniform(0, 1000) for i in range(random.randint(2, maxEltAmt))
]
- solution = math.sqrt(sum([i**2 for i in vec]))
+ solution = round(math.sqrt(sum([i**2 for i in vec])), 2)
- 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
+ problem = f"Euclidian norm or L2 norm of the vector ${vec}$ is:"
+ return problem, f'${solution}$'
euclidian_norm = Generator("Euclidian norm or L2 norm of a vector", 69,
diff --git a/mathgenerator/funcs/misc/factors.py b/mathgenerator/funcs/misc/factors.py
index 794764e1..cf85b946 100644
--- a/mathgenerator/funcs/misc/factors.py
+++ b/mathgenerator/funcs/misc/factors.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxVal=1000, format='string'):
+def gen_func(maxVal=1000):
n = random.randint(1, maxVal)
factors = []
@@ -18,14 +18,9 @@ def gen_func(maxVal=1000, format='string'):
factors.sort()
- if format == 'string':
- problem = f"Factors of {n} = "
- solution = factors
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return n, factors
+ problem = f"Factors of ${n} = $"
+ solution = factors
+ return problem, f'${solution}$'
factors = Generator("Factors of a number", 116, gen_func,
diff --git a/mathgenerator/funcs/misc/gcd.py b/mathgenerator/funcs/misc/gcd.py
index 23b28680..bdab2428 100644
--- a/mathgenerator/funcs/misc/gcd.py
+++ b/mathgenerator/funcs/misc/gcd.py
@@ -2,21 +2,16 @@
import random
-def gen_func(maxVal=20, format='string'):
+def gen_func(maxVal=20):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
x, y = a, b
while y:
x, y = y, x % y
- if 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
+ problem = f"GCD of ${a}$ and ${b} = $"
+ solution = f'${x}$'
+ return problem, solution
gcd = Generator("GCD (Greatest Common Denominator)", 10, gen_func,
diff --git a/mathgenerator/funcs/misc/geometric_mean.py b/mathgenerator/funcs/misc/geometric_mean.py
index 56b1ddfc..71e3422a 100644
--- a/mathgenerator/funcs/misc/geometric_mean.py
+++ b/mathgenerator/funcs/misc/geometric_mean.py
@@ -1,32 +1,19 @@
from ...generator import Generator
import random
+import numpy as np
-def gen_func(maxValue=100, maxNum=4, format='string'):
- a = random.randint(1, maxValue)
- b = random.randint(1, maxValue)
- c = random.randint(1, maxValue)
- d = random.randint(1, maxValue)
- num = random.randint(2, 4)
- if num == 2:
- product = a * b
- elif num == 3:
- product = a * b * c
- elif num == 4:
- product = a * b * c * d
+def gen_func(maxValue=100, maxCount=4):
+ count = random.randint(2, maxCount)
+ nums = [random.randint(1, maxValue) for i in range(count)]
+ product = np.prod(nums)
- ans = product**(1 / num)
- if num == 2:
- problem = f"Geometric mean of {num} numbers {a} and {b} = "
- solution = f"({a}*{b})^(1/{num}) = {ans}"
- elif num == 3:
- problem = f"Geometric mean of {num} numbers {a} , {b} and {c} = "
- solution = f"({a}*{b}*{c})^(1/{num}) = {ans}"
- elif num == 4:
- problem = f"Geometric mean of {num} numbers {a} , {b} , {c} , {d} = "
- solution = f"({a}*{b}*{c}*{d})^(1/{num}) = {ans}"
+ ans = round(product ** (1 / count), 2)
+ problem = f"Geometric mean of ${count}$ numbers ${nums} = $"
+ # solution = f"$({'*'.join(map(str, nums))}^{{\\frac{{1}}{{{count}}}}} = {ans}$"
+ solution = f"${ans}$"
return problem, solution
geometric_mean = Generator("Geometric Mean of N Numbers", 67,
- gen_func, ["maxValue=100", "maxNum=4"])
+ gen_func, ["maxValue=100", "maxCount=4"])
diff --git a/mathgenerator/funcs/misc/geometric_progression.py b/mathgenerator/funcs/misc/geometric_progression.py
index 5a9098c8..588c7e2a 100644
--- a/mathgenerator/funcs/misc/geometric_progression.py
+++ b/mathgenerator/funcs/misc/geometric_progression.py
@@ -6,8 +6,7 @@ def gen_func(number_values=6,
min_value=2,
max_value=12,
n_term=7,
- sum_term=5,
- format='string'):
+ sum_term=5):
r = random.randint(min_value, max_value)
a = random.randint(min_value, max_value)
n_term = random.randint(number_values, number_values + 5)
@@ -18,18 +17,10 @@ def gen_func(number_values=6,
value_nth_term = a * (r**(n_term - 1))
sum_till_nth_term = a * ((r**sum_term - 1) / (r - 1))
- if format == 'string':
- problem = "For the given GP " + str(
- GP) + " ,Find the value of a,common ratio," + str(
- n_term) + "th term value, sum upto " + str(
- sum_term) + "th term"
- 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
+ problem = f"For the given GP ${GP}$. Find the value of a common ratio, {n_term}th term value, sum upto {sum_term}th term"
+ 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
geometric_progression = Generator("Geometric Progression", 66, gen_func, [
diff --git a/mathgenerator/funcs/misc/harmonic_mean.py b/mathgenerator/funcs/misc/harmonic_mean.py
index 58569b19..c3ea1467 100644
--- a/mathgenerator/funcs/misc/harmonic_mean.py
+++ b/mathgenerator/funcs/misc/harmonic_mean.py
@@ -2,30 +2,16 @@
import random
-def gen_func(maxValue=100, maxNum=4, format='string'):
-
- a = random.randint(1, maxValue)
- b = random.randint(1, maxValue)
- c = random.randint(1, maxValue)
- d = random.randint(1, maxValue)
- num = random.randint(2, 4)
- if num == 2:
- sum = (1 / a) + (1 / b)
- elif num == 3:
- sum = (1 / a) + (1 / b) + (1 / c)
- elif num == 4:
- sum = (1 / a) + (1 / b) + (1 / c) + (1 / d)
-
+def gen_func(maxValue=100, maxCount=4):
+ count = random.randint(2, maxCount)
+ nums = [random.randint(1, maxValue) for _ in range(count)]
+ sum = 0
+ for num in nums:
+ sum += (1 / num)
ans = num / sum
- if num == 2:
- problem = f"Harmonic mean of {num} numbers {a} and {b} = "
- solution = f" {num}/((1/{a}) + (1/{b})) = {ans}"
- elif num == 3:
- problem = f"Harmonic mean of {num} numbers {a} , {b} and {c} = "
- solution = f" {num}/((1/{a}) + (1/{b}) + (1/{c})) = {ans}"
- elif num == 4:
- problem = f"Harmonic mean of {num} numbers {a} , {b} , {c} , {d} = "
- solution = f" {num}/((1/{a}) + (1/{b}) + (1/{c}) + (1/{d})) = {ans}"
+
+ problem = f"Harmonic mean of ${count}$ numbers ${', '.join(map(str, nums))} = $"
+ solution = f"${ans}$"
return problem, solution
diff --git a/mathgenerator/funcs/misc/hcf.py b/mathgenerator/funcs/misc/hcf.py
index 1c06f613..2d9bc019 100644
--- a/mathgenerator/funcs/misc/hcf.py
+++ b/mathgenerator/funcs/misc/hcf.py
@@ -2,21 +2,16 @@
import random
-def gen_func(maxVal=20, format='string'):
+def gen_func(maxVal=20):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
x, y = a, b
while (y):
x, y = y, x % y
- if 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
+ problem = f"HCF of ${a}$ and ${b} = $"
+ solution = f'${x}$'
+ return problem, solution
hcf = Generator("HCF (Highest Common Factor)", 51, gen_func, ["maxVal=20"])
diff --git a/mathgenerator/funcs/misc/is_leap_year.py b/mathgenerator/funcs/misc/is_leap_year.py
index b730e347..14c6c54d 100644
--- a/mathgenerator/funcs/misc/is_leap_year.py
+++ b/mathgenerator/funcs/misc/is_leap_year.py
@@ -2,9 +2,9 @@
import random
-def gen_func(minNumber=1900, maxNumber=2099, format='string'):
+def gen_func(minNumber=1900, maxNumber=2099):
year = random.randint(minNumber, maxNumber)
- problem = "Year " + str(year) + " "
+ problem = f"Is {year} a leap year?"
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
@@ -16,16 +16,8 @@ def gen_func(minNumber=1900, maxNumber=2099, format='string'):
else:
ans = False
- if format == 'string':
- if ans:
- solution = "is a leap year"
- else:
- solution = "is not a leap year"
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return year, ans
+ solution = f"{year} is{' not' if not ans else ''} a leap year"
+ return problem, solution
is_leap_year = Generator("Leap Year or Not", 101, gen_func,
diff --git a/mathgenerator/funcs/misc/lcm.py b/mathgenerator/funcs/misc/lcm.py
index e4200841..03aa13c1 100644
--- a/mathgenerator/funcs/misc/lcm.py
+++ b/mathgenerator/funcs/misc/lcm.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxVal=20, format='string'):
+def gen_func(maxVal=20):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
c = a * b
@@ -12,14 +12,9 @@ def gen_func(maxVal=20, format='string'):
x, y = y, x % y
d = c // x
- if 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
+ problem = f"LCM of ${a}$ and ${b} =$"
+ solution = f'${d}$'
+ return problem, solution
lcm = Generator("LCM (Least Common Multiple)", 9, gen_func, ["maxVal=20"])
diff --git a/mathgenerator/funcs/misc/minutes_to_hours.py b/mathgenerator/funcs/misc/minutes_to_hours.py
index 381e2a40..43d0ac0c 100644
--- a/mathgenerator/funcs/misc/minutes_to_hours.py
+++ b/mathgenerator/funcs/misc/minutes_to_hours.py
@@ -2,19 +2,14 @@
import random
-def gen_func(maxMinutes=999, format='string'):
+def gen_func(maxMinutes=999):
minutes = random.randint(1, maxMinutes)
- ansHours = int(minutes / 60)
+ ansHours = minutes // 60
ansMinutes = minutes % 60
- if 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
+ problem = f"Convert ${minutes}$ minutes to hours & minutes"
+ solution = f"${ansHours}$ hours and ${ansMinutes}$ minutes"
+ return problem, solution
minutes_to_hours = Generator("Minute to Hour conversion", 102,
diff --git a/mathgenerator/funcs/misc/prime_factors.py b/mathgenerator/funcs/misc/prime_factors.py
index 20f50059..f9e5496d 100644
--- a/mathgenerator/funcs/misc/prime_factors.py
+++ b/mathgenerator/funcs/misc/prime_factors.py
@@ -2,7 +2,7 @@
import random
-def gen_func(minVal=1, maxVal=200, format='string'):
+def gen_func(minVal=1, maxVal=200):
a = random.randint(minVal, maxVal)
n = a
i = 2
@@ -18,14 +18,9 @@ def gen_func(minVal=1, maxVal=200, format='string'):
if n > 1:
factors.append(n)
- if 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
+ problem = f"Find prime factors of ${a}$"
+ solution = f"${', '.join(map(str, factors))}$"
+ return problem, solution
prime_factors = Generator("Prime Factorisation", 27, gen_func,
diff --git a/mathgenerator/funcs/misc/product_of_scientific_notations.py b/mathgenerator/funcs/misc/product_of_scientific_notations.py
index 29e0a629..3d5dda5c 100644
--- a/mathgenerator/funcs/misc/product_of_scientific_notations.py
+++ b/mathgenerator/funcs/misc/product_of_scientific_notations.py
@@ -2,7 +2,7 @@
import random
-def gen_func(minExpVal=-100, maxExpVal=100, format='string'):
+def gen_func(minExpVal=-100, maxExpVal=100):
a = [round(random.uniform(1, 10), 2), random.randint(minExpVal, maxExpVal)]
b = [round(random.uniform(1, 10), 2), random.randint(minExpVal, maxExpVal)]
c = [a[0] * b[0], a[1] + b[1]]
@@ -11,15 +11,9 @@ def gen_func(minExpVal=-100, maxExpVal=100, format='string'):
c[0] /= 10
c[1] += 1
- if format == 'string':
- problem = "Product of scientific notations " + \
- str(a[0]) + "x10^" + str(a[1]) + " and " + str(b[0]) + "x10^" + str(b[1]) + " = "
- solution = str(round(c[0], 2)) + "x10^" + str(c[1])
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b, c
+ problem = f"Product of scientific notations ${a[0]} \\times 10^{{{a[1]}}}$ and ${b[0]} \\times 10^{{{b[1]}}} = $"
+ solution = f'${round(c[0], 2)} \\times 10^{{{c[1]}}}$'
+ return problem, solution
product_of_scientific_notations = Generator("Product of scientific notations", 121, gen_func,
diff --git a/mathgenerator/funcs/misc/profit_loss_percent.py b/mathgenerator/funcs/misc/profit_loss_percent.py
index cbe5e39c..35567c4c 100644
--- a/mathgenerator/funcs/misc/profit_loss_percent.py
+++ b/mathgenerator/funcs/misc/profit_loss_percent.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxCP=1000, maxSP=1000, format='string'):
+def gen_func(maxCP=1000, maxSP=1000):
cP = random.randint(1, maxCP)
sP = random.randint(1, maxSP)
diff = abs(sP - cP)
@@ -10,15 +10,10 @@ def gen_func(maxCP=1000, maxSP=1000, format='string'):
profitOrLoss = "Profit"
else:
profitOrLoss = "Loss"
- percent = diff / cP * 100
+ percent = round(diff / cP * 100, 2)
- 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
+ problem = f"{profitOrLoss} percent when $CP = {cP}$ and $SP = {sP}$ is: "
+ return problem, f'${percent}$'
profit_loss_percent = Generator("Profit or Loss Percent", 63,
diff --git a/mathgenerator/funcs/misc/quotient_of_power_same_base.py b/mathgenerator/funcs/misc/quotient_of_power_same_base.py
index 8eed6836..2a3d00d9 100644
--- a/mathgenerator/funcs/misc/quotient_of_power_same_base.py
+++ b/mathgenerator/funcs/misc/quotient_of_power_same_base.py
@@ -2,21 +2,16 @@
import random
-def gen_func(maxBase=50, maxPower=10, format='string'):
+def gen_func(maxBase=50, maxPower=10):
base = random.randint(1, maxBase)
power1 = random.randint(1, maxPower)
power2 = random.randint(1, maxPower)
step = power1 - power2
- solution = base**step
+ solution = base ** step
- if 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
+ problem = f"The Quotient of ${base}^{{{power1}}}$ and ${base}^{{{power2}}} = " \
+ f"${base}^{{{power1}-{power2}}} = {base}^{{{step}}}$"
+ return problem, f'${solution}$'
quotient_of_power_same_base = Generator("Quotient of Powers with Same Base",
diff --git a/mathgenerator/funcs/misc/quotient_of_power_same_power.py b/mathgenerator/funcs/misc/quotient_of_power_same_power.py
index df5c6513..8d6be1d7 100644
--- a/mathgenerator/funcs/misc/quotient_of_power_same_power.py
+++ b/mathgenerator/funcs/misc/quotient_of_power_same_power.py
@@ -2,21 +2,16 @@
import random
-def gen_func(maxBase=50, maxPower=10, format='string'):
+def gen_func(maxBase=50, maxPower=10):
base1 = random.randint(1, maxBase)
base2 = random.randint(1, maxBase)
power = random.randint(1, maxPower)
step = base1 / base2
- solution = step**power
+ solution = step ** power
- if 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
+ problem = f"The Quotient of ${base1}^{{{power}}}$ and ${base2}^{{{power}}} = " \
+ f"({base1}/{base2})^{power} = {step}^{{{power}}}$"
+ return problem, f'${solution}$'
quotient_of_power_same_power = Generator("Quotient of Powers with Same Power",
diff --git a/mathgenerator/funcs/misc/set_operation.py b/mathgenerator/funcs/misc/set_operation.py
index 95c36916..80d50918 100644
--- a/mathgenerator/funcs/misc/set_operation.py
+++ b/mathgenerator/funcs/misc/set_operation.py
@@ -2,25 +2,23 @@
import random
-def gen_func(minval=3, maxval=7, n_a=4, n_b=5, format='string'):
+def gen_func(minval=3, maxval=7, n_a=4, n_b=5):
number_variables_a = random.randint(minval, maxval)
number_variables_b = random.randint(minval, maxval)
a = []
b = []
- for i in range(number_variables_a):
+ for _ in range(number_variables_a):
a.append(random.randint(1, 10))
- for i in range(number_variables_b):
+ for _ in range(number_variables_b):
b.append(random.randint(1, 10))
a = set(a)
b = set(b)
- problem = "Given the two sets a=" + \
- str(a) + " ,b=" + str(b) + \
- ".Find the Union,intersection,a-b,b-a and symmetric difference"
- solution = "Union is " + str(a.union(b)) + ",Intersection is " + str(
- a.intersection(b)) + ", a-b is " + str(
- a.difference(b)) + ",b-a is " + str(
- b.difference(a)) + ", Symmetric difference is " + str(
- a.symmetric_difference(b))
+
+ problem = f"Given the two sets $a={a}$, $b={b}. " + \
+ "Find the Union, intersection, a-b, b-a, and symmetric difference"
+ solution = f"Union is ${a.union(b)}$. Intersection is ${a.intersection(b)}$" + \
+ f", a-b is ${a.difference(b)}$, b-a is ${b.difference(a)}$." + \
+ f" Symmetric difference is ${a.symmetric_difference(b)}$."
return problem, solution
diff --git a/mathgenerator/funcs/misc/signum_function.py b/mathgenerator/funcs/misc/signum_function.py
index fd113b66..ce202ce5 100644
--- a/mathgenerator/funcs/misc/signum_function.py
+++ b/mathgenerator/funcs/misc/signum_function.py
@@ -2,7 +2,7 @@
import random
-def gen_func(min=-999, max=999, format='string'):
+def gen_func(min=-999, max=999):
a = random.randint(min, max)
b = 0
if (a > 0):
@@ -10,14 +10,9 @@ def gen_func(min=-999, max=999, format='string'):
if (a < 0):
b = -1
- if format == 'string':
- problem = "signum of " + str(a) + " is " + "="
- solution = str(b)
- return problem, solution
- elif format == 'latex':
- return "Latex unavailable"
- else:
- return a, b
+ problem = f"signum of {a} is ="
+ solution = f'${b}$'
+ return problem, solution
signum_function = Generator("signum function", 106, gen_func,
diff --git a/mathgenerator/funcs/misc/surds_comparison.py b/mathgenerator/funcs/misc/surds_comparison.py
index 830e8ee4..cd32a125 100644
--- a/mathgenerator/funcs/misc/surds_comparison.py
+++ b/mathgenerator/funcs/misc/surds_comparison.py
@@ -3,7 +3,7 @@
import math
-def gen_func(maxValue=100, maxRoot=10, format='string'):
+def gen_func(maxValue=100, maxRoot=10):
radicand1, radicand2 = tuple(random.sample(range(1, maxValue), 2))
degree1, degree2 = tuple(random.sample(range(1, maxRoot), 2))
first = math.pow(radicand1, 1 / degree1)
@@ -15,13 +15,8 @@ def gen_func(maxValue=100, maxRoot=10, format='string'):
elif first < second:
solution = "<"
- 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
+ problem = f"Fill in the blanks ${radicand1}^{{\\frac{{1}}{{{degree1}}}}}$ _ ${radicand2}^{{\\frac{{1}}{{{degree2}}}}}$"
+ return problem, f'${solution}$'
surds_comparison = Generator("Comparing surds", 55, gen_func,
diff --git a/mathgenerator/funcs/statistics/combinations.py b/mathgenerator/funcs/statistics/combinations.py
index 83d38664..c314b685 100644
--- a/mathgenerator/funcs/statistics/combinations.py
+++ b/mathgenerator/funcs/statistics/combinations.py
@@ -1,27 +1,16 @@
from ...generator import Generator
import random
+import math
-def gen_func(maxlength=20, format='string'):
- def factorial(a):
- d = 1
- for i in range(a):
- a = (i + 1) * d
- d = a
- return d
-
+def gen_func(maxlength=20):
a = random.randint(10, maxlength)
b = random.randint(0, 9)
- solution = int(factorial(a) / (factorial(b) * factorial(a - b)))
+ solution = int(math.factorial(a) / (math.factorial(b) * math.factorial(a - b)))
- 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
+ problem = f"Find the number of combinations from ${a}$ objects picked ${b}$ at a time."
+ return problem, f'${solution}$'
combinations = Generator("Combinations of Objects", 30, gen_func,
diff --git a/mathgenerator/funcs/statistics/conditional_probability.py b/mathgenerator/funcs/statistics/conditional_probability.py
index 05ebbb32..5bff5dee 100644
--- a/mathgenerator/funcs/statistics/conditional_probability.py
+++ b/mathgenerator/funcs/statistics/conditional_probability.py
@@ -2,7 +2,7 @@
import random
-def gen_func(format='string'):
+def gen_func():
P_disease = round(2. * random.random(), 2)
true_positive = round(random.random() + float(random.randint(90, 99)), 2)
true_negative = round(random.random() + float(random.randint(90, 99)), 2)
@@ -18,17 +18,12 @@ def BayesFormula(P_disease, true_positive, true_negative):
answer = round(BayesFormula(P_disease, true_positive, true_negative), 2)
- if format == 'string':
- problem = "Someone tested positive for a nasty disease which only {0:.2f}% of population have. " \
- "Test sensitivity (true positive) is equal to SN= {1:.2f}% whereas test specificity (true negative) SP= {2:.2f}%. " \
- "What is the probability that this guy really has that disease?".format(
- 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
+ problem = "Someone tested positive for a nasty disease which only ${0:.2f}\\%$ of the population have. " \
+ "Test sensitivity (true positive) is equal to $SN={1:.2f}$% whereas test specificity (true negative) $SP={2:.2f}\\%$. " \
+ "What is the probability that this guy really has that disease?".format(
+ P_disease, true_positive, true_negative)
+ solution = f'${answer}$%'
+ return problem, solution
conditional_probability = Generator("Conditional Probability", 107,
diff --git a/mathgenerator/funcs/statistics/confidence_interval.py b/mathgenerator/funcs/statistics/confidence_interval.py
index 6300fe11..b993c1bb 100644
--- a/mathgenerator/funcs/statistics/confidence_interval.py
+++ b/mathgenerator/funcs/statistics/confidence_interval.py
@@ -3,7 +3,7 @@
import math
-def gen_func(format='string'):
+def gen_func():
n = random.randint(20, 40)
j = random.randint(0, 3)
@@ -29,15 +29,10 @@ def gen_func(format='string'):
upper = mean + standard_error
lower = mean - standard_error
- if format == 'string':
- problem = 'The confidence interval for sample {} with {}% confidence is'.format(
- [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
+ problem = 'The confidence interval for sample ${}$ with ${}$% confidence is'.format(
+ [x for x in lst], lst_per[j])
+ solution = f'$({upper}, {lower})$'
+ return problem, solution
confidence_interval = Generator("Confidence interval For sample S", 54,
diff --git a/mathgenerator/funcs/statistics/data_summary.py b/mathgenerator/funcs/statistics/data_summary.py
index 7892832e..8b586e74 100644
--- a/mathgenerator/funcs/statistics/data_summary.py
+++ b/mathgenerator/funcs/statistics/data_summary.py
@@ -2,7 +2,7 @@
import random
-def gen_func(number_values=15, minval=5, maxval=50, format='string'):
+def gen_func(number_values=15, minval=5, maxval=50):
random_list = []
for i in range(number_values):
@@ -17,17 +17,11 @@ def gen_func(number_values=15, minval=5, maxval=50, format='string'):
var += (random_list[i] - mean)**2
standardDeviation = var / number_values
- variance = (var / number_values)**0.5
-
- if format == 'string':
- problem = "Find the mean,standard deviation and variance for the data" + \
- 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
+ variance = (var / number_values) ** 0.5
+
+ problem = f"Find the mean,standard deviation and variance for the data ${', '.join(map(str, random_list))}$"
+ solution = f"The Mean is ${mean}$, Standard Deviation is ${standardDeviation}$, Variance is ${variance}$"
+ return problem, solution
data_summary = Generator("Mean,Standard Deviation,Variance", 59,
diff --git a/mathgenerator/funcs/statistics/dice_sum_probability.py b/mathgenerator/funcs/statistics/dice_sum_probability.py
index ad55c725..b89d4547 100644
--- a/mathgenerator/funcs/statistics/dice_sum_probability.py
+++ b/mathgenerator/funcs/statistics/dice_sum_probability.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxDice=3, format='string'):
+def gen_func(maxDice=3):
a = random.randint(1, maxDice)
b = random.randint(a, 6 * a)
@@ -21,14 +21,9 @@ def gen_func(maxDice=3, format='string'):
if i + j + k == b:
count = count + 1
- if 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
+ problem = f"If ${a}$ dice are rolled at the same time, the probability of getting a sum of ${b} =$"
+ solution = f"\\frac{{{count}}}{{{6**a}}}"
+ return problem, solution
dice_sum_probability = Generator(
diff --git a/mathgenerator/funcs/statistics/mean_median.py b/mathgenerator/funcs/statistics/mean_median.py
index 7330462f..bc79d8a3 100644
--- a/mathgenerator/funcs/statistics/mean_median.py
+++ b/mathgenerator/funcs/statistics/mean_median.py
@@ -2,7 +2,7 @@
import random
-def gen_func(maxlen=10, format='string'):
+def gen_func(maxlen=10):
randomlist = random.sample(range(1, 99), maxlen)
total = 0
for n in randomlist:
@@ -11,14 +11,9 @@ def gen_func(maxlen=10, format='string'):
randomlist.sort()
median = (randomlist[4] + randomlist[5]) / 2
- if 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
+ 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
mean_median = Generator("Mean and Median", 76, gen_func, ["maxlen=10"])
diff --git a/mathgenerator/funcs/statistics/permutation.py b/mathgenerator/funcs/statistics/permutation.py
index d3f3d27a..44fd3361 100644
--- a/mathgenerator/funcs/statistics/permutation.py
+++ b/mathgenerator/funcs/statistics/permutation.py
@@ -3,19 +3,13 @@
import math
-def gen_func(maxlength=20, format='string'):
+def gen_func(maxlength=20):
a = random.randint(10, maxlength)
b = random.randint(0, 9)
- answer = int(math.factorial(a) / (math.factorial(a - b)))
+ solution = int(math.factorial(a) / (math.factorial(a - b)))
- if 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
+ problem = f"Number of Permutations from ${a}$ objects picked ${b}$ at a time is: "
+ return problem, f"${solution}$"
permutation = Generator("Permutations", 42, gen_func, ["maxlength=20"])
diff --git a/mathgenerator/latexBuilder.py b/mathgenerator/latexBuilder.py
new file mode 100644
index 00000000..5a208cdb
--- /dev/null
+++ b/mathgenerator/latexBuilder.py
@@ -0,0 +1,14 @@
+def frac(num, den):
+ return f'\\frac{{{num}}}{{{den}}}'
+
+
+def bmatrix(lst):
+ """Turns 2d matrix into a bmatrix"""
+ out = '\\begin{bmatrix} '
+ lst = [' & '.join(map(str, row)) for row in lst]
+ out += ' \\\\ '.join(lst)
+ return out + ' \\end{bmatrix}'
+
+
+def exp(base, exp):
+ return f'{base}^{{{exp}}}'
diff --git a/tests/test_mathgen.py b/tests/test_mathgen.py
deleted file mode 100644
index 879fdac3..00000000
--- a/tests/test_mathgen.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from math import sqrt
-from mathgenerator.mathgen import *
-
-from hypothesis import strategies as st, given, assume
-
-
-@given(maxSum=st.integers(min_value=1), maxAddend=st.integers(min_value=1))
-def test_addition(maxSum, maxAddend):
- assume(maxSum > maxAddend)
- problem, solution = addition.func(maxSum, maxAddend)
- assert eval(problem[:-1]) == int(solution)
-
-
-@given(maxMinuend=st.integers(min_value=1), maxDiff=st.integers(min_value=1))
-def test_subtraction(maxMinuend, maxDiff):
- assume(maxMinuend > maxDiff)
- problem, solution = subtraction.func(maxMinuend, maxDiff)
- assert eval(problem[:-1]) == int(solution)
-
-
-@given(maxMulti=st.integers(min_value=1))
-def test_multiplication(maxMulti):
- problem, solution = multiplication.func(maxMulti)
- assert eval(problem[:-1]) == int(solution)
-
-
-@given(maxA=st.integers(min_value=1), maxB=st.integers(min_value=1))
-def test_division(maxA, maxB):
- assume(maxA > maxB)
- problem, solution = division.func(maxA, maxB)
- assert eval(problem[:-1]) == int(solution)
-
-
-@given(maxRes=st.integers(min_value=1), maxModulo=st.integers(min_value=1))
-def test_modulo_division(maxRes, maxModulo):
- assume(maxRes > maxModulo)
- problem, solution = modulo_division.func(maxRes, maxModulo)
- assert eval(problem[:-1]) == int(solution)
-
-
-@given(minNo=st.integers(min_value=1),
- maxNo=st.integers(min_value=1, max_value=2**50))
-def test_square_root(minNo, maxNo):
- assume(maxNo > minNo)
- problem, solution = square_root.func(minNo, maxNo)
- assert eval(problem[:-1]) == float(solution)