diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index 4e1ef42..495e3c3 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -1,5 +1,5 @@
# This workflows will upload a Python Package using Twine when a release is created
-# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
+# For more information see https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Upload Python Package
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index cc6cf9d..49d0e4c 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -4,20 +4,29 @@ on: [push, pull_request]
jobs:
build:
-
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: '3.x'
- - name: Install dependencies
- run: |
- python -m pip install -U pip
- python -m pip install -r dev-requirements.txt
- - name: Linter
- run: make lint
- - name: Test
- run: make test
+ - uses: actions/checkout@v2
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.x"
+
+ - uses: actions/cache@v1
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Install Dependencies
+ if: steps.cache.outputs.cache-hit != 'true'
+ run: make deps
+
+ - name: Linter
+ run: make lint
+
+ - name: Test
+ run: make test
diff --git a/Makefile b/Makefile
index e5dca74..eb91e5e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,15 @@
IGNORE_ERRORS = E501,F401,F403,F405
PKG = mathgenerator
+PYTHON ?= python3
+
+deps:
+ $(PYTHON) -m pip install --user -r dev-requirements.txt
format:
- python -m autopep8 --ignore=$(IGNORE_ERRORS) -ir $(PKG)/*
+ $(PYTHON) -m autopep8 --ignore=$(IGNORE_ERRORS) -ir $(PKG)/*
lint:
- python -m flake8 --ignore=$(IGNORE_ERRORS) $(PKG)
+ $(PYTHON) -m flake8 --ignore=$(IGNORE_ERRORS) $(PKG)
test:
- python -m pytest --verbose -s tests
+ $(PYTHON) -m pytest --verbose -s tests
diff --git a/README.md b/README.md
index 2bdc428..a8d3aa9 100644
--- a/README.md
+++ b/README.md
@@ -31,93 +31,100 @@ problem, solution = mathgen.genById(0)
| Id | Skill | Example problem | Example Solution | Function Name |
|------|-----------------------------------|--------------------|-----------------------|--------------------------|
[//]: # list start
-| 0 | Addition | 29+29= | 58 | addition |
-| 1 | Subtraction | 10-8= | 2 | subtraction |
-| 2 | Multiplication | 96*0= | 0 | multiplication |
-| 3 | Division | 25/95= | 0.2631578947368421 | division |
-| 4 | Binary Complement 1s | 100101100= | 011010011 | binary_complement_1s |
-| 5 | Modulo Division | 74%50= | 24 | modulo_division |
-| 6 | Square Root | sqrt(49)= | 7 | square_root |
-| 7 | Power Rule Differentiation | 10x^7 + 7x^5 + 5x^8 | 70x^6 + 35x^4 + 40x^7 | power_rule_differentiation |
-| 8 | Square | 9^2= | 81 | square |
-| 9 | LCM (Least Common Multiple) | LCM of 19 and 7 = | 133 | lcm |
-| 10 | GCD (Greatest Common Denominator) | GCD of 1 and 7 = | 1 | gcd |
-| 11 | Basic Algebra | 3x + 2 = 8 | 6 | basic_algebra |
+| 0 | Addition | 13+0= | 13 | addition |
+| 1 | Subtraction | 95-6= | 89 | subtraction |
+| 2 | Multiplication | 66*0= | 0 | multiplication |
+| 3 | Division | 15/42= | 0.35714285714285715 | division |
+| 4 | Binary Complement 1s | 01= | 10 | binary_complement_1s |
+| 5 | Modulo Division | 59%11= | 4 | modulo_division |
+| 6 | Square Root | sqrt(81)= | 9 | square_root |
+| 7 | Power Rule Differentiation | 8x^2 + 3x^3 + 1x^9 | 16x^1 + 9x^2 + 9x^8 | power_rule_differentiation |
+| 8 | Square | 3^2= | 9 | square |
+| 9 | LCM (Least Common Multiple) | LCM of 8 and 4 = | 8 | lcm |
+| 10 | GCD (Greatest Common Denominator) | GCD of 12 and 12 = | 12 | gcd |
+| 11 | Basic Algebra | 8x + 10 = 10 | 0 | basic_algebra |
| 12 | Logarithm | log2(128) | 7 | log |
-| 13 | Easy Division | 228/12 = | 19 | int_division |
-| 14 | Decimal to Binary | Binary of 37= | 100101 | decimal_to_binary |
-| 15 | Binary to Decimal | 10100001 | 161 | binary_to_decimal |
-| 16 | Fraction Division | (8/2)/(8/2) | 1 | divide_fractions |
-| 17 | Integer Multiplication with 2x2 Matrix | 6 * [[3, 7], [10, 6]] = | [[18,42],[60,36]] | multiply_int_to_22_matrix |
-| 18 | Area of Triangle | Area of triangle with side lengths: 2 1 19 = | (5.449334243437888e-15+88.99438184514796j) | area_of_triangle |
-| 19 | Triangle exists check | Does triangle with sides 48, 16 and 30 exist? | No | valid_triangle |
-| 20 | Midpoint of the two point | (2,-5),(12,-7)= | (7.0,-6.0) | midpoint_of_two_points |
-| 21 | Factoring Quadratic | x^2-18x+81 | (x-9)(x-9) | factoring |
-| 22 | Third Angle of Triangle | Third angle of triangle with angles 45 and 1 = | 134 | third_angle_of_triangle |
-| 23 | Solve a System of Equations in R^2 | -7x - 10y = -133, 7x - 2y = 49 | x = 9, y = 7 | system_of_equations |
-| 24 | Distance between 2 points | Find the distance between (-10, 7) and (16, 6) | sqrt(677) | distance_two_points |
-| 25 | Pythagorean Theorem | The hypotenuse of a right triangle given the other two lengths 10 and 8 = | 12.81 | pythagorean_theorem |
-| 26 | Linear Equations | 18x + -2y = -174, -13x + 6y = 194 | x = -8, y = 15 | linear_equations |
-| 27 | Prime Factorisation | Find prime factors of 16 | [2, 2, 2, 2] | prime_factors |
-| 28 | Fraction Multiplication | (6/8)*(2/5) | 3/10 | fraction_multiplication |
-| 29 | Angle of a Regular Polygon | Find the angle of a regular polygon with 17 sides | 158.82 | angle_regular_polygon |
-| 30 | Combinations of Objects | Number of combinations from 17 objects picked 3 at a time | 680 | combinations |
-| 31 | Factorial | 1! = | 1 | factorial |
-| 32 | Surface Area of Cube | Surface area of cube with side = 17m is | 1734 m^2 | surface_area_cube |
-| 33 | Surface Area of Cuboid | Surface area of cuboid with sides = 12m, 11m, 1m is | 310 m^2 | surface_area_cuboid |
-| 34 | Surface Area of Cylinder | Surface area of cylinder with height = 38m and radius = 16m is | 5428 m^2 | surface_area_cylinder |
-| 35 | Volum of Cube | Volume of cube with side = 11m is | 1331 m^3 | volume_cube |
-| 36 | Volume of Cuboid | Volume of cuboid with sides = 17m, 19m, 8m is | 2584 m^3 | volume_cuboid |
-| 37 | Volume of cylinder | Volume of cylinder with height = 35m and radius = 19m is | 39694 m^3 | volume_cylinder |
-| 38 | Surface Area of cone | Surface area of cone with height = 8m and radius = 19m is | 2364 m^2 | surface_area_cone |
-| 39 | Volume of cone | Volume of cone with height = 43m and radius = 13m is | 7609 m^3 | volume_cone |
-| 40 | Common Factors | Common Factors of 21 and 65 = | [1] | common_factors |
-| 41 | Intersection of Two Lines | Find the point of intersection of the two lines: y = 5/4x - 1 and y = 0/4x - 5 | (-16/5, -5) | intersection_of_two_lines |
-| 42 | Permutations | Number of Permutations from 10 objects picked 5 at a time = | 30240 | permutation |
-| 43 | Cross Product of 2 Vectors | [12, -16, 4] X [-14, 10, -9] = | [104, 52, -104] | vector_cross |
-| 44 | Compare Fractions | Which symbol represents the comparison between 7/10 and 7/5? | < | compare_fractions |
-| 45 | Simple Interest | Simple interest for a principle amount of 6138 dollars, 9% rate of interest and for a time period of 8 years is = | 4419.36 | simple_interest |
-| 46 | Multiplication of two matrices | Multiply
and | | matrix_multiplication |
-| 47 | Cube Root | cuberoot of 633 upto 2 decimal places is: | 8.59 | cube_root |
-| 48 | Power Rule Integration | 2x^5 + 3x^3 + 4x^7 + 9x^1 + 6x^9 | (2/5)x^6 + (3/3)x^4 + (4/7)x^8 + (9/1)x^2 + (6/9)x^10 + c | power_rule_integration |
-| 49 | Fourth Angle of Quadrilateral | Fourth angle of quadrilateral with angles 79 , 44, 37 = | 200 | fourth_angle_of_quadrilateral |
-| 50 | Quadratic Equation | Zeros of the Quadratic Equation 79x^2+182x+98=0 | [-0.86, -1.45] | quadratic_equation |
-| 51 | HCF (Highest Common Factor) | HCF of 1 and 20 = | 1 | hcf |
-| 52 | Probability of a certain sum appearing on faces of dice | If 1 dice are rolled at the same time, the probability of getting a sum of 2 = | 1/6 | dice_sum_probability |
-| 53 | Exponentiation | 6^9 = | 10077696 | exponentiation |
-| 54 | Confidence interval For sample S | The confidence interval for sample [260, 249, 281, 261, 236, 237, 275, 229, 256, 242, 277, 240, 278, 293, 271, 255, 216, 292, 200, 298, 282, 223] with 99% confidence is | (271.2437114485249, 242.48356127874783) | confidence_interval |
-| 55 | Comparing surds | Fill in the blanks 71^(1/5) _ 31^(1/8) | > | surds_comparison |
-| 56 | Fibonacci Series | The Fibonacci Series of the first 19 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584] | fibonacci_series |
+| 13 | Easy Division | 230/10 = | 23 | int_division |
+| 14 | Decimal to Binary | Binary of 93= | 1011101 | decimal_to_binary |
+| 15 | Binary to Decimal | 10001 | 17 | binary_to_decimal |
+| 16 | Fraction Division | (4/3)/(4/8) | 8/3 | divide_fractions |
+| 17 | Integer Multiplication with 2x2 Matrix | 11 * [[6, 2], [0, 8]] = | [[66,22],[0,88]] | multiply_int_to_22_matrix |
+| 18 | Area of Triangle | Area of triangle with side lengths: 10 17 7 = | 0.0 | area_of_triangle |
+| 19 | Triangle exists check | Does triangle with sides 13, 40 and 7 exist? | No | valid_triangle |
+| 20 | Midpoint of the two point | (-16,-17),(7,11)= | (-4.5,-3.0) | midpoint_of_two_points |
+| 21 | Factoring Quadratic | x^2-3x-18 | (x-6)(x+3) | factoring |
+| 22 | Third Angle of Triangle | Third angle of triangle with angles 49 and 13 = | 118 | third_angle_of_triangle |
+| 23 | Solve a System of Equations in R^2 | 3x + y = 18, 4x + 10y = 102 | x = 3, y = 9 | system_of_equations |
+| 24 | Distance between 2 points | Find the distance between (-15, -13) and (-5, -10) | sqrt(109) | distance_two_points |
+| 25 | Pythagorean Theorem | The hypotenuse of a right triangle given the other two lengths 14 and 13 = | 19.10 | pythagorean_theorem |
+| 26 | Linear Equations | -9x + -17y = 417, -1x + -4y = 78 | x = -18, y = -15 | linear_equations |
+| 27 | Prime Factorisation | Find prime factors of 196 | [2, 2, 7, 7] | prime_factors |
+| 28 | Fraction Multiplication | (8/1)*(9/6) | 12 | fraction_multiplication |
+| 29 | Angle of a Regular Polygon | Find the angle of a regular polygon with 8 sides | 135.0 | angle_regular_polygon |
+| 30 | Combinations of Objects | Number of combinations from 12 objects picked 2 at a time | 66 | combinations |
+| 31 | Factorial | 4! = | 24 | factorial |
+| 32 | Surface Area of Cube | Surface area of cube with side = 14m is | 1176 m^2 | surface_area_cube |
+| 33 | Surface Area of Cuboid | Surface area of cuboid with sides = 16m, 4m, 12m is | 608 m^2 | surface_area_cuboid |
+| 34 | Surface Area of Cylinder | Surface area of cylinder with height = 8m and radius = 13m is | 1715 m^2 | surface_area_cylinder |
+| 35 | Volum of Cube | Volume of cube with side = 14m is | 2744 m^3 | volume_cube |
+| 36 | Volume of Cuboid | Volume of cuboid with sides = 5m, 19m, 11m is | 1045 m^3 | volume_cuboid |
+| 37 | Volume of cylinder | Volume of cylinder with height = 26m and radius = 12m is | 11762 m^3 | volume_cylinder |
+| 38 | Surface Area of cone | Surface area of cone with height = 13m and radius = 8m is | 584 m^2 | surface_area_cone |
+| 39 | Volume of cone | Volume of cone with height = 45m and radius = 12m is | 6785 m^3 | volume_cone |
+| 40 | Common Factors | Common Factors of 53 and 11 = | [1] | common_factors |
+| 41 | Intersection of Two Lines | Find the point of intersection of the two lines: y = -9/6x + 2 and y = 5/4x - 6 | (32/11, -26/11) | intersection_of_two_lines |
+| 42 | Permutations | Number of Permutations from 12 objects picked 5 at a time = | 95040 | permutation |
+| 43 | Cross Product of 2 Vectors | [-19, 13, 14] X [7, 17, -11] = | [-381, -111, -414] | vector_cross |
+| 44 | Compare Fractions | Which symbol represents the comparison between 7/8 and 3/4? | > | compare_fractions |
+| 45 | Simple Interest | Simple interest for a principle amount of 4874 dollars, 10% rate of interest and for a time period of 1 years is = | 487.4 | simple_interest |
+| 46 | Multiplication of two matrices | Multiplyand | | matrix_multiplication |
+| 47 | Cube Root | cuberoot of 190 upto 2 decimal places is: | 5.75 | cube_root |
+| 48 | Power Rule Integration | 3x^2 + 7x^7 + 1x^6 + 9x^1 | (3/2)x^3 + (7/7)x^8 + (1/6)x^7 + (9/1)x^2 + c | power_rule_integration |
+| 49 | Fourth Angle of Quadrilateral | Fourth angle of quadrilateral with angles 126 , 81, 61 = | 92 | fourth_angle_of_quadrilateral |
+| 50 | Quadratic Equation | Zeros of the Quadratic Equation 6x^2+139x+34=0 | [-0.25, -22.92] | quadratic_equation |
+| 51 | HCF (Highest Common Factor) | HCF of 19 and 12 = | 1 | hcf |
+| 52 | Probability of a certain sum appearing on faces of dice | If 2 dice are rolled at the same time, the probability of getting a sum of 5 = | 4/36 | dice_sum_probability |
+| 53 | Exponentiation | 15^7 = | 170859375 | exponentiation |
+| 54 | Confidence interval For sample S | The confidence interval for sample [204, 279, 272, 203, 275, 286, 253, 237, 271, 222, 297, 265, 242, 239, 259, 241, 261, 254, 217, 219, 298, 273, 238, 209, 268] with 80% confidence is | (258.3266706388717, 244.23332936112834) | confidence_interval |
+| 55 | Comparing surds | Fill in the blanks 95^(1/7) _ 67^(1/6) | < | surds_comparison |
+| 56 | Fibonacci Series | The Fibonacci Series of the first 18 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597] | fibonacci_series |
| 57 | Trigonometric Values | What is cos(45)? | 1/√2 | basic_trigonometry |
-| 58 | Sum of Angles of Polygon | Sum of angles of polygon with 10 sides = | 1440 | sum_of_polygon_angles |
-| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[13, 22, 36, 17, 9, 39, 50, 14, 32, 40, 37, 48, 47, 28, 47] | The Mean is 31.933333333333334 , Standard Deviation is 182.59555555555553, Variance is 13.51279229306643 | data_summary |
+| 58 | Sum of Angles of Polygon | Sum of angles of polygon with 7 sides = | 900 | sum_of_polygon_angles |
+| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[41, 44, 15, 26, 15, 50, 27, 22, 11, 32, 14, 8, 23, 50, 9] | The Mean is 25.8 , Standard Deviation is 199.0933333333333, Variance is 14.110043704160994 | data_summary |
| 60 | Surface Area of Sphere | Surface area of Sphere with radius = 18m is | 4071.5040790523717 m^2 | surface_area_sphere |
-| 61 | Volume of Sphere | Volume of sphere with radius 61 m = | 950775.7894726198 m^3 | volume_sphere |
-| 62 | nth Fibonacci number | What is the 85th Fibonacci number? | 259695496911123328 | nth_fibonacci_number |
-| 63 | Profit or Loss Percent | Profit percent when CP = 353 and SP = 752 is: | 113.03116147308782 | profit_loss_percent |
-| 64 | Binary to Hexidecimal | 111101011 | 0x1eb | binary_to_hex |
-| 65 | Multiplication of 2 complex numbers | (-19-9j) * (-17-2j) = | (305+191j) | multiply_complex_numbers |
-| 66 | Geometric Progression | For the given GP [7, 77, 847, 9317, 102487, 1127357] ,Find the value of a,common ratio,6th term value, sum upto 7th term | The value of a is 7, common ratio is 11 , 6th term is 1127357 , sum upto 7th term is 13641019.0 | geometric_progression |
-| 67 | Geometric Mean of N Numbers | Geometric mean of 3 numbers 32 , 5 and 18 = | (32*5*18)^(1/3) = 14.227573217960249 | geometric_mean |
-| 68 | Harmonic Mean of N Numbers | Harmonic mean of 3 numbers 48 , 85 and 79 = | 3/((1/48) + (1/85) + (1/79)) = 66.28916158223076 | harmonic_mean |
-| 69 | Euclidian norm or L2 norm of a vector | Euclidian norm or L2 norm of the vector[743.1109024649227, 951.2861991520674, 821.2679183199273, 831.5922742303677, 972.3005129207023, 775.1712986008336, 869.5254070360901, 34.05779748860371, 495.5299489221041, 516.2458991121815, 620.0871728488738, 12.438787805084894, 967.8138977993306, 627.6791615554401, 129.81896901435886, 566.4442009627315, 521.5300881726977, 741.5947979192599] is: | 2917.827115551868 | euclidian_norm |
-| 70 | Angle between 2 vectors | angle between the vectors [341.1766244080324, 386.90517658729595, 306.3074773969527, 542.1138441520038, 149.80203485453225, 85.6719016065689, 875.0827941729921, 292.0422074695527, 312.8929536855103, 408.95388654647445, 119.81564007869672, 177.5529661884936, 360.30983184002406, 111.71502530193955, 29.528755078141455, 478.2846569662712, 855.8978282979257] and [230.45166329807688, 922.2895458023412, 219.89492715268733, 375.8793126730714, 731.2614314505195, 277.5554009411926, 329.1490487358273, 477.7600322879586, 168.93745868538923, 423.6897582803929, 724.5555882496458, 519.6421532094823, 158.0479000313908, 679.3674240323584, 496.6795371750926, 853.4421897526636, 715.2567898992207] is: | NaN | angle_btw_vectors |
-| 71 | Absolute difference between two numbers | Absolute difference between numbers 53 and -70 = | 123 | absolute_difference |
-| 72 | Dot Product of 2 Vectors | [-8, -4, -10] . [-9, -6, -9] = | 186 | vector_dot |
-| 73 | Binary 2's Complement | 2's complement of = | | binary_2s_complement |
-| 74 | Inverse of a Matrix | Inverse of Matrix Matrix([[43, 95, 41], [46, 80, 67], [57, 75, 71]]) is: | Matrix([[131/7038, -367/3519, 617/7038], [553/35190, 358/17595, -199/7038], [-37/1173, 73/1173, -31/1173]]) | invert_matrix |
-| 75 | Area of a Sector | Given radius, 40 and angle, 199. Find the area of the sector. | Area of sector = 2778.56417 | sector_area |
-| 76 | Mean and Median | Given the series of numbers [44, 64, 22, 37, 63, 56, 27, 62, 98, 72]. find the arithmatic mean and mdian of the series | Arithmetic mean of the series is 54.5 and Arithmetic median of this series is 59.0 | mean_median |
-| 77 | Determinant to 2x2 Matrix | Det([[73, 52], [55, 80]]) = | 2980 | int_matrix_22_determinant |
-| 78 | Compound Interest | Compound Interest for a principle amount of 8506 dollars, 8% rate of interest and for a time period of 10 compounded monthly is = | 8506.0 | compound_interest |
-| 79 | Decimal to Hexadecimal | Binary of 293= | 0x125 | decimal_to_hexadeci |
-| 80 | Percentage of a number | What is 57% of 4? | Required percentage = 2.28% | percentage |
-| 81 | Celsius To Fahrenheit | Convert 57 degrees Celsius to degrees Fahrenheit = | 134.60000000000002 | celsius_to_fahrenheit |
-| 82 | AP Term Calculation | Find the term number 89 of the AP series: 20, 115, 210 ... | 8380 | arithmetic_progression_term |
-| 83 | AP Sum Calculation | Find the sum of first 98 terms of the AP series: -58, -106, -154 ... | -233828.0 | arithmetic_progression_sum |
-| 84 | Converts decimal to octal | The decimal number 1716 in Octal is: | 0o3264 | decimal_to_octal |
-| 85 | Converts decimal to Roman Numerals | The number 587 in Roman Numerals is: | DLXXXVII | decimal_to_roman_numerals |
-| 86 | Degrees to Radians | Angle 245 in radians is = | 4.28 | degree_to_rad |
+| 61 | Volume of Sphere | Volume of sphere with radius 88 m = | 2854543.2384361913 m^3 | volume_sphere |
+| 62 | nth Fibonacci number | What is the 5th Fibonacci number? | 5 | nth_fibonacci_number |
+| 63 | Profit or Loss Percent | Profit percent when CP = 190 and SP = 653 is: | 243.68421052631578 | profit_loss_percent |
+| 64 | Binary to Hexidecimal | 000 | 0x0 | binary_to_hex |
+| 65 | Multiplication of 2 complex numbers | (1+11j) * (14-20j) = | (234+134j) | multiply_complex_numbers |
+| 66 | Geometric Progression | For the given GP [2, 14, 98, 686, 4802, 33614] ,Find the value of a,common ratio,11th term value, sum upto 10th term | The value of a is 2, common ratio is 7 , 11th term is 564950498 , sum upto 10th term is 94158416.0 | geometric_progression |
+| 67 | Geometric Mean of N Numbers | Geometric mean of 4 numbers 5 , 36 , 46 , 11 = | (5*36*46*11)^(1/4) = 17.372237396461717 | geometric_mean |
+| 68 | Harmonic Mean of N Numbers | Harmonic mean of 4 numbers 2 , 69 , 40 , 85 = | 4/((1/2) + (1/69) + (1/40) + (1/85)) = 7.256137637734391 | harmonic_mean |
+| 69 | Euclidian norm or L2 norm of a vector | Euclidian norm or L2 norm of the vector[964.0224705098824, 282.67364534639074, 10.524202601537414, 361.644358207216, 691.8214421455904, 573.8396623606926, 972.293614400242, 140.0274501909099, 590.7302519633489, 797.8763197329738, 726.1188608418418, 597.5706485157848, 241.28898511522024, 694.0267219296932, 32.85273313007875, 187.58082258543695, 452.179970384704, 964.184342568536, 589.6017896365979, 936.6845704453358] is: | 2778.1660192850186 | euclidian_norm |
+| 70 | Angle between 2 vectors | angle between the vectors [682.87, 786.47, 315.92, 912.87, 542.62, 602.89, 747.77, 437.42, 3.35, 225.43, 63.6, 535.22, 871.05, 33.58] and [625.58, 654.32, 738.64, 670.61, 575.02, 237.12, 220.81, 78.57, 298.55, 427.21, 396.95, 159.78, 574.71, 847.07] is: | 0.69 radians | angle_btw_vectors |
+| 71 | Absolute difference between two numbers | Absolute difference between numbers -14 and 27 = | 41 | absolute_difference |
+| 72 | Dot Product of 2 Vectors | [13, -5, -16] . [-6, 11, -2] = | -101 | vector_dot |
+| 73 | Binary 2's Complement | 2's complement of 10 = | 10 | binary_2s_complement |
+| 74 | Inverse of a Matrix | Inverse of Matrix Matrix([[73, 79, 98], [11, 18, 14], [41, 47, 26]]) is: | Matrix([[95/6388, -319/1597, 329/6388], [-36/1597, 265/1597, -7/1597], [221/12776, 24/1597, -445/12776]]) | invert_matrix |
+| 75 | Area of a Sector | Given radius, 7 and angle, 271. Find the area of the sector. | Area of sector = 115.88114 | sector_area |
+| 76 | Mean and Median | Given the series of numbers [17, 84, 55, 4, 28, 41, 50, 54, 35, 14]. find the arithmatic mean and mdian of the series | Arithmetic mean of the series is 38.2 and Arithmetic median of this series is 38.0 | mean_median |
+| 77 | Determinant to 2x2 Matrix | Det([[0, 38], [92, 69]]) = | -3496 | int_matrix_22_determinant |
+| 78 | Compound Interest | Compound interest for a principle amount of 6315 dollars, 4% rate of interest and for a time period of 8 year is = | 8642.51 | compound_interest |
+| 79 | Decimal to Hexadecimal | Binary of 222= | 0xde | decimal_to_hexadeci |
+| 80 | Percentage of a number | What is 16% of 10? | Required percentage = 1.60% | percentage |
+| 81 | Celsius To Fahrenheit | Convert -30 degrees Celsius to degrees Fahrenheit = | -22.0 | celsius_to_fahrenheit |
+| 82 | AP Term Calculation | Find the term number 23 of the AP series: -14, 86, 186 ... | 2186 | arithmetic_progression_term |
+| 83 | AP Sum Calculation | Find the sum of first 70 terms of the AP series: 55, -34, -123 ... | -211085.0 | arithmetic_progression_sum |
+| 84 | Converts decimal to octal | The decimal number 2801 in Octal is: | 0o5361 | decimal_to_octal |
+| 85 | Converts decimal to Roman Numerals | The number 1366 in Roman Numerals is: | MCCCLXVI | decimal_to_roman_numerals |
+| 86 | Degrees to Radians | Angle 213 in radians is = | 3.72 | degree_to_rad |
| 87 | Radians to Degrees | Angle 0 in degrees is = | 0.0 | radian_to_deg |
-| 88 | Differentiation | differentiate w.r.t x : d(exp(x)+5*x^(-2))/dx | exp(x) - 10/x^3 | differentiation |
-| 89 | Definite Integral of Quadratic Equation | The definite integral within limits 0 to 1 of the equation 39x^2 + 72x + 74 is = | 123.0 | definite_integral |
+| 88 | Differentiation | differentiate w.r.t x : d(ln(x)+5*x^3)/dx | 15*x^2 + 1/x | differentiation |
+| 89 | Definite Integral of Quadratic Equation | The definite integral within limits 0 to 1 of the equation 18x^2 + 37x + 1 is = | 25.5 | definite_integral |
+| 90 | isprime | 53 | True | is_prime |
+| 91 | Binary Coded Decimal to Integer | Integer of Binary Coded Decimal 1 is = | 5202 | bcd_to_decimal |
+| 92 | Complex To Polar Form | rexp(itheta) = | 10.3exp(i0.51) | complex_to_polar |
+| 93 | Union,Intersection,Difference of Two Sets | Given the two sets a={1, 2, 6, 7, 9, 10} ,b={9, 3, 5, 6}.Find the Union,intersection,a-b,b-a and symmetric difference | Union is {1, 2, 3, 5, 6, 7, 9, 10},Intersection is {9, 6}, a-b is {1, 2, 10, 7},b-a is {3, 5}, Symmetric difference is {1, 2, 3, 5, 7, 10} | set_operation |
+| 94 | Base Conversion | Convert 137673 from base 8 to base 10. | 49083 | base_conversion |
+| 95 | Curved surface area of a cylinder | What is the curved surface area of a cylinder of radius, 20 and height, 96? | CSA of cylinder = 12063.72 | curved_surface_area_cylinder |
+| 96 | Perimeter of Polygons | The perimeter of a 10 sided polygon with lengths of [106, 31, 107, 44, 44, 81, 108, 92, 75, 103]cm is: | 791 | perimeter_of_polygons |
diff --git a/mathgenerator/__init__.py b/mathgenerator/__init__.py
index 090e18a..45ca62f 100644
--- a/mathgenerator/__init__.py
+++ b/mathgenerator/__init__.py
@@ -11,7 +11,8 @@ class Generator:
self.generalSol = generalSol
self.func = func
- (filename, line_number, function_name, text) = traceback.extract_stack()[-2]
+ (filename, line_number, function_name,
+ text) = traceback.extract_stack()[-2]
funcname = filename[filename.rfind('/'):].strip()
funcname = funcname[1:-3]
# print(funcname)
diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py
index ca08fe5..c48f9d8 100644
--- a/mathgenerator/funcs/__init__.py
+++ b/mathgenerator/funcs/__init__.py
@@ -95,4 +95,13 @@ from .radian_to_deg import *
from .differentiation import *
from .definite_integral import *
from .is_prime import *
+from .bcd_to_decimal import *
+from .complex_to_polar import *
+from .set_operation import *
+from .base_conversion import *
+from .curved_surface_area_cylinder import *
+from .perimeter_of_polygons import *
+from .power_of_powers import *
+from .quotient_of_power_same_base import *
+from .quotient_of_power_same_power import *
from .complex_quadratic import *
diff --git a/mathgenerator/funcs/angle_btw_vectors.py b/mathgenerator/funcs/angle_btw_vectors.py
index f3b8a65..cc9923c 100644
--- a/mathgenerator/funcs/angle_btw_vectors.py
+++ b/mathgenerator/funcs/angle_btw_vectors.py
@@ -4,17 +4,17 @@ import math
def angleBtwVectorsFunc(maxEltAmt=20):
s = 0
- v1 = [random.uniform(0, 1000) for i in range(random.randint(2, maxEltAmt))]
- v2 = [random.uniform(0, 1000) for i in v1]
- for i in v1:
- for j in v2:
- s += i * j
+ v1 = [round(random.uniform(0, 1000), 2) for i in range(random.randint(2, maxEltAmt))]
+ v2 = [round(random.uniform(0, 1000), 2) for i in v1]
+ for i in range(len(v1)):
+ s += v1[i] * v2[i]
- mags = math.sqrt(sum([i**2 for i in v1])) * math.sqrt(sum([i**2 for i in v2]))
+ mags = math.sqrt(sum([i**2
+ for i in v1])) * math.sqrt(sum([i**2 for i in v2]))
problem = f"angle between the vectors {v1} and {v2} is:"
solution = ''
try:
- solution = str(math.acos(s / mags))
+ solution = str(round(math.acos(s / mags), 2)) + " radians"
except ValueError:
print('angleBtwVectorsFunc has some issues with math module, line 16')
solution = 'NaN'
diff --git a/mathgenerator/funcs/arithmetic_progression_sum.py b/mathgenerator/funcs/arithmetic_progression_sum.py
index e376c3f..d698354 100644
--- a/mathgenerator/funcs/arithmetic_progression_sum.py
+++ b/mathgenerator/funcs/arithmetic_progression_sum.py
@@ -8,11 +8,13 @@ def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
a3 = a2 + d
n = random.randint(4, maxn)
apString = str(a1) + ', ' + str(a2) + ', ' + str(a3) + ' ... '
- problem = 'Find the sum of first ' + str(n) + ' terms of the AP series: ' + apString
+ problem = 'Find the sum of first ' + str(
+ n) + ' terms of the AP series: ' + apString
solution = n * ((2 * a1) + ((n - 1) * d)) / 2
return problem, solution
-arithmetic_progression_sum = Generator("AP Sum Calculation", 83,
- "Find the sum of first n terms of the AP series: a1, a2, a3 ...",
- "Sum", arithmeticProgressionSumFunc)
+arithmetic_progression_sum = Generator(
+ "AP Sum Calculation", 83,
+ "Find the sum of first n terms of the AP series: a1, a2, a3 ...", "Sum",
+ arithmeticProgressionSumFunc)
diff --git a/mathgenerator/funcs/arithmetic_progression_term.py b/mathgenerator/funcs/arithmetic_progression_term.py
index 8468921..cdf1f9b 100644
--- a/mathgenerator/funcs/arithmetic_progression_term.py
+++ b/mathgenerator/funcs/arithmetic_progression_term.py
@@ -8,11 +8,13 @@ def arithmeticProgressionTermFunc(maxd=100, maxa=100, maxn=100):
a3 = a2 + d
n = random.randint(4, maxn)
apString = str(a1) + ', ' + str(a2) + ', ' + str(a3) + ' ... '
- problem = 'Find the term number ' + str(n) + ' of the AP series: ' + apString
+ problem = 'Find the term number ' + str(
+ n) + ' of the AP series: ' + apString
solution = a1 + ((n - 1) * d)
return problem, solution
-arithmetic_progression_term = Generator("AP Term Calculation", 82,
- "Find the term number n of the AP series: a1, a2, a3 ...",
- "a-n", arithmeticProgressionTermFunc)
+arithmetic_progression_term = Generator(
+ "AP Term Calculation", 82,
+ "Find the term number n of the AP series: a1, a2, a3 ...", "a-n",
+ arithmeticProgressionTermFunc)
diff --git a/mathgenerator/funcs/base_conversion.py b/mathgenerator/funcs/base_conversion.py
new file mode 100644
index 0000000..02746ff
--- /dev/null
+++ b/mathgenerator/funcs/base_conversion.py
@@ -0,0 +1,58 @@
+from .__init__ import *
+
+# base from 2 to 36
+alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+
+def fromBaseTenTo(n, toBase):
+ assert type(
+ toBase
+ ) == int and toBase >= 2 and toBase <= 36, "toBase({}) must be >=2 and <=36"
+ # trivial cases
+ if toBase == 2:
+ return bin(n)[2:]
+ elif toBase == 8:
+ return oct(n)[2:]
+ elif toBase == 10:
+ return str(n)
+ elif toBase == 16:
+ return hex(n)[2:].upper()
+ res = alpha[n % toBase]
+ n = n // toBase
+ while n > 0:
+ res = alpha[n % toBase] + res
+ n = n // toBase
+ return res
+
+
+# Useful to check answers, but not needed here
+# def toBaseTen(n,fromBase):
+# return int(n,fromBase)
+
+
+def baseConversionFunc(maxNum=60000, maxBase=16):
+ assert type(
+ maxNum
+ ) == int and maxNum >= 100 and maxNum <= 65536, "maxNum({}) must be >=100 and <=65536".format(
+ maxNum)
+ assert type(
+ maxBase
+ ) == int and maxBase >= 2 and maxBase <= 36, "maxBase({}) must be >= 2 and <=36".format(
+ maxBase)
+
+ n = random.randint(40, maxNum)
+ dist = [10] * 10 + [2] * 5 + [16] * 5 + [i for i in range(2, maxBase + 1)]
+ # set this way since converting to/from bases 2,10,16 are more common -- can be changed if needed.
+ bases = random.choices(dist, k=2)
+ while bases[0] == bases[1]:
+ bases = random.choices(dist, k=2)
+
+ problem = "Convert {} from base {} to base {}.".format(
+ fromBaseTenTo(n, bases[0]), bases[0], bases[1])
+ ans = fromBaseTenTo(n, bases[1])
+ return problem, ans
+
+
+base_conversion = Generator("Base Conversion", 94,
+ "Convert 152346 from base 8 to base 10.", "54502",
+ baseConversionFunc)
diff --git a/mathgenerator/funcs/bcd_to_decimal.py b/mathgenerator/funcs/bcd_to_decimal.py
new file mode 100644
index 0000000..ec48176
--- /dev/null
+++ b/mathgenerator/funcs/bcd_to_decimal.py
@@ -0,0 +1,25 @@
+from .__init__ import *
+
+
+def BCDtoDecimalFunc(maxNumber=10000):
+ n = random.randint(1000, maxNumber)
+ binstring = ''
+ while True:
+ q, r = divmod(n, 10)
+ nibble = bin(r).replace('0b', "")
+ while len(nibble) < 4:
+ nibble = '0' + nibble
+ binstring = nibble + binstring
+ if q == 0:
+ break
+ else:
+ n = q
+
+ problem = "Integer of Binary Coded Decimal " + str(n) + " is = "
+ solution = int(binstring, 2)
+ return problem, solution
+
+
+bcd_to_decimal = Generator("Binary Coded Decimal to Integer", 91,
+ "Integer of Binary Coded Decimal b is ", "n",
+ BCDtoDecimalFunc)
diff --git a/mathgenerator/funcs/binary_to_hex.py b/mathgenerator/funcs/binary_to_hex.py
index 77b03b1..bb3d993 100644
--- a/mathgenerator/funcs/binary_to_hex.py
+++ b/mathgenerator/funcs/binary_to_hex.py
@@ -11,5 +11,5 @@ def binaryToHexFunc(max_dig=10):
return problem, solution
-binary_to_hex = Generator("Binary to Hexidecimal", 64, "Hexidecimal of a=", "b",
- binaryToHexFunc)
+binary_to_hex = Generator("Binary to Hexidecimal", 64, "Hexidecimal of a=",
+ "b", binaryToHexFunc)
diff --git a/mathgenerator/funcs/celsius_to_fahrenheit.py b/mathgenerator/funcs/celsius_to_fahrenheit.py
index 45122d0..f314883 100644
--- a/mathgenerator/funcs/celsius_to_fahrenheit.py
+++ b/mathgenerator/funcs/celsius_to_fahrenheit.py
@@ -4,10 +4,12 @@ from .__init__ import *
def celsiustofahrenheitFunc(maxTemp=100):
celsius = random.randint(-50, maxTemp)
fahrenheit = (celsius * (9 / 5)) + 32
- problem = "Convert " + str(celsius) + " degrees Celsius to degrees Fahrenheit ="
+ problem = "Convert " + str(
+ celsius) + " degrees Celsius to degrees Fahrenheit ="
solution = str(fahrenheit)
return problem, solution
celsius_to_fahrenheit = Generator("Celsius To Fahrenheit", 81,
- "(C +(9/5))+32=", "F", celsiustofahrenheitFunc)
+ "(C +(9/5))+32=", "F",
+ celsiustofahrenheitFunc)
diff --git a/mathgenerator/funcs/complex_to_polar.py b/mathgenerator/funcs/complex_to_polar.py
new file mode 100644
index 0000000..ad4798d
--- /dev/null
+++ b/mathgenerator/funcs/complex_to_polar.py
@@ -0,0 +1,18 @@
+from .__init__ import *
+
+
+def complexToPolarFunc(minRealImaginaryNum=-20, maxRealImaginaryNum=20):
+ num = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum),
+ random.randint(minRealImaginaryNum, maxRealImaginaryNum))
+ a = num.real
+ b = num.imag
+ r = round(math.hypot(a, b), 2)
+ theta = round(math.atan2(b, a), 2)
+ plr = str(r) + "exp(i" + str(theta) + ")"
+ problem = "rexp(itheta) = "
+ solution = plr
+ return problem, solution
+
+
+complex_to_polar = Generator("Complex To Polar Form", 92, "rexp(itheta) = ",
+ "plr", complexToPolarFunc)
diff --git a/mathgenerator/funcs/compound_interest.py b/mathgenerator/funcs/compound_interest.py
index 4278d10..0ff034c 100644
--- a/mathgenerator/funcs/compound_interest.py
+++ b/mathgenerator/funcs/compound_interest.py
@@ -1,24 +1,19 @@
from .__init__ import *
-def compoundInterestFunc(maxPrinciple=10000,
- maxRate=10,
- maxTime=10,
- maxPeriod=10):
- p = random.randint(100, maxPrinciple)
+def compoundInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
+ p = random.randint(1000, maxPrinciple)
r = random.randint(1, maxRate)
- t = random.randint(1, maxTime)
- n = random.randint(1, maxPeriod)
- A = p * ((1 + (r / (100 * n))**(n * t)))
- problem = "Compound Interest for a principle amount of " + str(
- p) + " dollars, " + str(
- r) + "% rate of interest and for a time period of " + str(
- t) + " compounded monthly is = "
- solution = round(A, 2)
+ n = random.randint(1, maxTime)
+ a = p * (1 + r / 100)**n
+ 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 = "
+ solution = round(a, 2)
return problem, solution
compound_interest = Generator(
"Compound Interest", 78,
- "Compound interest for a principle amount of p dollars, r% rate of interest and for a time period of t years with n times compounded annually is = ",
- "A dollars", compoundInterestFunc)
+ "Compound interest for a principle amount of a dollars, b% rate of interest and for a time period of c years is = ",
+ "d dollars", compoundInterestFunc)
diff --git a/mathgenerator/funcs/cube_root.py b/mathgenerator/funcs/cube_root.py
index 041d492..06a6a8d 100644
--- a/mathgenerator/funcs/cube_root.py
+++ b/mathgenerator/funcs/cube_root.py
@@ -10,5 +10,6 @@ def cubeRootFunc(minNo=1, maxNo=1000):
return problem, solution
-cube_root = Generator("Cube Root", 47, "Cuberoot of a upto 2 decimal places is",
- "b", cubeRootFunc)
+cube_root = Generator("Cube Root", 47,
+ "Cuberoot of a upto 2 decimal places is", "b",
+ cubeRootFunc)
diff --git a/mathgenerator/funcs/curved_surface_area_cylinder.py b/mathgenerator/funcs/curved_surface_area_cylinder.py
new file mode 100644
index 0000000..0a02325
--- /dev/null
+++ b/mathgenerator/funcs/curved_surface_area_cylinder.py
@@ -0,0 +1,17 @@
+from .__init__ import *
+
+
+def curvedSurfaceAreaCylinderFunc(maxRadius=49, maxHeight=99):
+ r = random.randint(1, maxRadius)
+ h = random.randint(1, maxHeight)
+ problem = f"What is the curved surface area of a cylinder of radius, {r} and height, {h}?"
+ csa = float(2 * math.pi * r * h)
+ formatted_float = round(csa, 2) # "{:.5f}".format(csa)
+ solution = f"CSA of cylinder = {formatted_float}"
+ return problem, solution
+
+
+curved_surface_area_cylinder = Generator(
+ "Curved surface area of a cylinder", 95,
+ "What is CSA of a cylinder of radius, r and height, h?", "csa of cylinder",
+ curvedSurfaceAreaCylinderFunc)
diff --git a/mathgenerator/funcs/data_summary.py b/mathgenerator/funcs/data_summary.py
index a84a91c..f74bf8e 100644
--- a/mathgenerator/funcs/data_summary.py
+++ b/mathgenerator/funcs/data_summary.py
@@ -16,7 +16,7 @@ def dataSummaryFunc(number_values=15, minval=5, maxval=50):
var += (random_list[i] - mean)**2
standardDeviation = var / number_values
- variance = (var / number_values) ** 0.5
+ variance = (var / number_values)**0.5
problem = "Find the mean,standard deviation and variance for the data" + \
str(random_list)
diff --git a/mathgenerator/funcs/decimal_to_octal.py b/mathgenerator/funcs/decimal_to_octal.py
index 5a89b99..e6a2ca9 100644
--- a/mathgenerator/funcs/decimal_to_octal.py
+++ b/mathgenerator/funcs/decimal_to_octal.py
@@ -9,4 +9,5 @@ def decimalToOctalFunc(maxDecimal=4096):
decimal_to_octal = Generator("Converts decimal to octal", 84,
- "What's the octal representation of 98?", "0o142", decimalToOctalFunc)
+ "What's the octal representation of 98?", "0o142",
+ decimalToOctalFunc)
diff --git a/mathgenerator/funcs/decimal_to_roman_numerals.py b/mathgenerator/funcs/decimal_to_roman_numerals.py
index 46a1ebd..c2470dc 100644
--- a/mathgenerator/funcs/decimal_to_roman_numerals.py
+++ b/mathgenerator/funcs/decimal_to_roman_numerals.py
@@ -4,7 +4,15 @@ from .__init__ import *
def decimalToRomanNumeralsFunc(maxDecimal=4000):
x = random.randint(0, maxDecimal)
problem = "The number " + str(x) + " in Roman Numerals is: "
- roman_dict = {1: "I", 5: "V", 10: "X", 50: "L", 100: "C", 500: "D", 1000: "M"}
+ roman_dict = {
+ 1: "I",
+ 5: "V",
+ 10: "X",
+ 50: "L",
+ 100: "C",
+ 500: "D",
+ 1000: "M"
+ }
divisor = 1
while x >= divisor:
divisor *= 10
@@ -15,7 +23,7 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000):
if last_value <= 3:
solution += (roman_dict[divisor] * last_value)
elif last_value == 4:
- solution += (roman_dict[divisor] * roman_dict[divisor * 5])
+ solution += (roman_dict[divisor] + roman_dict[divisor * 5])
elif 5 <= last_value <= 8:
solution += (roman_dict[divisor * 5] + (roman_dict[divisor] * (last_value - 5)))
elif last_value == 9:
@@ -25,5 +33,6 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000):
return problem, solution
-decimal_to_roman_numerals = Generator("Converts decimal to Roman Numerals",
- 85, "Convert 20 into Roman Numerals", "XX", decimalToRomanNumeralsFunc)
+decimal_to_roman_numerals = Generator("Converts decimal to Roman Numerals", 85,
+ "Convert 20 into Roman Numerals", "XX",
+ decimalToRomanNumeralsFunc)
diff --git a/mathgenerator/funcs/definite_integral.py b/mathgenerator/funcs/definite_integral.py
index 6e8453f..7a46027 100644
--- a/mathgenerator/funcs/definite_integral.py
+++ b/mathgenerator/funcs/definite_integral.py
@@ -4,9 +4,8 @@ from scipy.integrate import quad
def definiteIntegralFunc(max_coeff=100):
-
def integrand(x, a, b, c):
- return a * x ** 2 + b * x + c
+ return a * x**2 + b * x + c
a = random.randint(0, max_coeff)
b = random.randint(0, max_coeff)
@@ -23,5 +22,7 @@ def definiteIntegralFunc(max_coeff=100):
return problem, solution
-definite_integral = Generator("Definite Integral of Quadratic Equation", 89,
- "The definite integral within limits 0 to 1 of quadratic equation ax^2+bx+c is = ", "S", definiteIntegralFunc)
+definite_integral = Generator(
+ "Definite Integral of Quadratic Equation", 89,
+ "The definite integral within limits 0 to 1 of quadratic equation ax^2+bx+c is = ",
+ "S", definiteIntegralFunc)
diff --git a/mathgenerator/funcs/degree_to_rad.py b/mathgenerator/funcs/degree_to_rad.py
index dc63f10..a17d72f 100644
--- a/mathgenerator/funcs/degree_to_rad.py
+++ b/mathgenerator/funcs/degree_to_rad.py
@@ -13,5 +13,5 @@ def degreeToRadFunc(max_deg=360):
return problem, solution
-degree_to_rad = Generator("Degrees to Radians", 86,
- "Angle a in radians is = ", "b", degreeToRadFunc)
+degree_to_rad = Generator("Degrees to Radians", 86, "Angle a in radians is = ",
+ "b", degreeToRadFunc)
diff --git a/mathgenerator/funcs/differentiation.py b/mathgenerator/funcs/differentiation.py
index 2b40dea..1c0205d 100644
--- a/mathgenerator/funcs/differentiation.py
+++ b/mathgenerator/funcs/differentiation.py
@@ -49,5 +49,6 @@ def differentiationFunc(diff_lvl=2):
return problem, solution
-differentiation = Generator(
- "Differentiation", 88, "differentiate w.r.t x : d(f(x))/dx", "g(x)", differentiationFunc)
+differentiation = Generator("Differentiation", 88,
+ "differentiate w.r.t x : d(f(x))/dx", "g(x)",
+ differentiationFunc)
diff --git a/mathgenerator/funcs/distance_two_points.py b/mathgenerator/funcs/distance_two_points.py
index 6dc6b7d..7277702 100644
--- a/mathgenerator/funcs/distance_two_points.py
+++ b/mathgenerator/funcs/distance_two_points.py
@@ -14,6 +14,7 @@ def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
return problem, solution
-distance_two_points = Generator("Distance between 2 points", 24,
- "Find the distance between (x1,y1) and (x2,y2)",
- "sqrt(distanceSquared)", distanceTwoPointsFunc)
+distance_two_points = Generator(
+ "Distance between 2 points", 24,
+ "Find the distance between (x1,y1) and (x2,y2)", "sqrt(distanceSquared)",
+ distanceTwoPointsFunc)
diff --git a/mathgenerator/funcs/euclidian_norm.py b/mathgenerator/funcs/euclidian_norm.py
index cfd178c..017fa74 100644
--- a/mathgenerator/funcs/euclidian_norm.py
+++ b/mathgenerator/funcs/euclidian_norm.py
@@ -2,12 +2,15 @@ from .__init__ import *
def euclidianNormFunc(maxEltAmt=20):
- vec = [random.uniform(0, 1000) for i in range(random.randint(2, maxEltAmt))]
+ vec = [
+ random.uniform(0, 1000) for i in range(random.randint(2, maxEltAmt))
+ ]
problem = f"Euclidian norm or L2 norm of the vector{vec} is:"
solution = math.sqrt(sum([i**2 for i in vec]))
return problem, solution
-eucldian_norm = Generator("Euclidian norm or L2 norm of a vector", 69,
- "Euclidian Norm of a vector V:[v1, v2, ......., vn]",
- "sqrt(v1^2 + v2^2 ........ +vn^2)", euclidianNormFunc)
+eucldian_norm = Generator(
+ "Euclidian norm or L2 norm of a vector", 69,
+ "Euclidian Norm of a vector V:[v1, v2, ......., vn]",
+ "sqrt(v1^2 + v2^2 ........ +vn^2)", euclidianNormFunc)
diff --git a/mathgenerator/funcs/geometric_mean.py b/mathgenerator/funcs/geometric_mean.py
index 034ddf2..606269e 100644
--- a/mathgenerator/funcs/geometric_mean.py
+++ b/mathgenerator/funcs/geometric_mean.py
@@ -27,6 +27,7 @@ def geometricMeanFunc(maxValue=100, maxNum=4):
return problem, solution
-geometric_mean = Generator("Geometric Mean of N Numbers", 67,
- "Geometric mean of n numbers A1 , A2 , ... , An = ",
- "(A1*A2*...An)^(1/n) = ans", geometricMeanFunc)
+geometric_mean = Generator(
+ "Geometric Mean of N Numbers", 67,
+ "Geometric mean of n numbers A1 , A2 , ... , An = ",
+ "(A1*A2*...An)^(1/n) = ans", geometricMeanFunc)
diff --git a/mathgenerator/funcs/invert_matrix.py b/mathgenerator/funcs/invert_matrix.py
index 7a196c5..f089c3c 100644
--- a/mathgenerator/funcs/invert_matrix.py
+++ b/mathgenerator/funcs/invert_matrix.py
@@ -78,5 +78,6 @@ def matrixInversion(SquareMatrixDimension=3,
return problem, solution
-invert_matrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is",
- "A^(-1)", matrixInversion)
+invert_matrix = Generator("Inverse of a Matrix", 74,
+ "Inverse of a matrix A is", "A^(-1)",
+ matrixInversion)
diff --git a/mathgenerator/funcs/is_prime.py b/mathgenerator/funcs/is_prime.py
index 143f4d3..ac3ede5 100644
--- a/mathgenerator/funcs/is_prime.py
+++ b/mathgenerator/funcs/is_prime.py
@@ -18,5 +18,5 @@ def isprime(max_a=100):
return (problem, solution)
-is_prime = Generator('isprime', 90, 'a any positive integer',
- 'True/False', isprime)
+is_prime = Generator('isprime', 90, 'a any positive integer', 'True/False',
+ isprime)
diff --git a/mathgenerator/funcs/midpoint_of_two_points.py b/mathgenerator/funcs/midpoint_of_two_points.py
index 2b021aa..9e458a4 100644
--- a/mathgenerator/funcs/midpoint_of_two_points.py
+++ b/mathgenerator/funcs/midpoint_of_two_points.py
@@ -13,5 +13,6 @@ def MidPointOfTwoPointFunc(maxValue=20):
midPoint_of_two_points = Generator("Midpoint of the two point", 20,
- "((X1,Y1),(X2,Y2))=", "((X1+X2)/2,(Y1+Y2)/2)",
+ "((X1,Y1),(X2,Y2))=",
+ "((X1+X2)/2,(Y1+Y2)/2)",
MidPointOfTwoPointFunc)
diff --git a/mathgenerator/funcs/perimeter_of_polygons.py b/mathgenerator/funcs/perimeter_of_polygons.py
new file mode 100644
index 0000000..e15402d
--- /dev/null
+++ b/mathgenerator/funcs/perimeter_of_polygons.py
@@ -0,0 +1,18 @@
+from .__init__ import *
+
+
+def perimeterOfPolygons(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]
+ return problem, solution
+
+
+perimeter_of_polygons = Generator(
+ "Perimeter of Polygons", 96, "The perimeter of a x sided polygon with lengths of y cm is: ", "z", perimeterOfPolygons)
diff --git a/mathgenerator/funcs/power_of_powers.py b/mathgenerator/funcs/power_of_powers.py
new file mode 100644
index 0000000..5892a57
--- /dev/null
+++ b/mathgenerator/funcs/power_of_powers.py
@@ -0,0 +1,20 @@
+from .__init__ import *
+
+
+def powerOfPowersFunc(maxBase=50, maxPower=10):
+ base = random.randint(1, maxBase)
+ power1 = random.randint(1, maxPower)
+ power2 = random.randint(1, maxPower)
+ step = power1 * power2
+
+ problem = "The {base}^{power1}^{power2} = " \
+ "{base}^({power1}*{power2}) = {base}^{step}".format(base=base,
+ power1=power1,
+ power2=power2,
+ step=step)
+ solution = str(base ** step)
+ return problem, solution
+
+
+power_of_powers = Generator("Power of Powers", 97,
+ "6^4^2 = 6^(4*2) = 6^6", "46656", powerOfPowersFunc)
diff --git a/mathgenerator/funcs/power_rule_differentiation.py b/mathgenerator/funcs/power_rule_differentiation.py
index cdc8c76..25a85c2 100644
--- a/mathgenerator/funcs/power_rule_differentiation.py
+++ b/mathgenerator/funcs/power_rule_differentiation.py
@@ -18,6 +18,6 @@ def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
return problem, solution
-power_rule_differentiation = Generator("Power Rule Differentiation", 7, "nx^m=",
- "(n*m)x^(m-1)",
+power_rule_differentiation = Generator("Power Rule Differentiation", 7,
+ "nx^m=", "(n*m)x^(m-1)",
powerRuleDifferentiationFunc)
diff --git a/mathgenerator/funcs/quotient_of_power_same_base.py b/mathgenerator/funcs/quotient_of_power_same_base.py
new file mode 100644
index 0000000..79449d2
--- /dev/null
+++ b/mathgenerator/funcs/quotient_of_power_same_base.py
@@ -0,0 +1,20 @@
+from .__init__ import *
+
+
+def quotientOfPowerSameBaseFunc(maxBase=50, maxPower=10):
+ base = random.randint(1, maxBase)
+ power1 = random.randint(1, maxPower)
+ power2 = random.randint(1, maxPower)
+ step = power1 - power2
+
+ problem = "The Quotient of {base}^{power1} and {base}^{power2} = " \
+ "{base}^({power1}-{power2}) = {base}^{step}".format(base=base,
+ power1=power1,
+ power2=power2,
+ step=step)
+ solution = str(base ** step)
+ return problem, solution
+
+
+quotient_of_power_same_base = Generator("Quotient of Powers with Same Base", 98,
+ "6^4 / 6^2 = 6^(4-2) = 6^2", "36", quotientOfPowerSameBaseFunc)
diff --git a/mathgenerator/funcs/quotient_of_power_same_power.py b/mathgenerator/funcs/quotient_of_power_same_power.py
new file mode 100644
index 0000000..0c647db
--- /dev/null
+++ b/mathgenerator/funcs/quotient_of_power_same_power.py
@@ -0,0 +1,20 @@
+from .__init__ import *
+
+
+def quotientOfPowerSamePowerFunc(maxBase=50, maxPower=10):
+ base1 = random.randint(1, maxBase)
+ base2 = random.randint(1, maxBase)
+ power = random.randint(1, maxPower)
+ step = base1 / base2
+
+ problem = "The Quotient of {base1}^{power} and {base2}^{power} = " \
+ "({base1}/{base2})^{power} = {step}^{power}".format(base1=base1,
+ base2=base2,
+ power=power,
+ step=step)
+ solution = str(step ** power)
+ return problem, solution
+
+
+quotient_of_power_same_power = Generator("Quotient of Powers with Same Power", 99,
+ "6^4 / 3^4 = (6/3)^4 = 2^4", "16", quotientOfPowerSamePowerFunc)
diff --git a/mathgenerator/funcs/radian_to_deg.py b/mathgenerator/funcs/radian_to_deg.py
index e48acc0..0281b82 100644
--- a/mathgenerator/funcs/radian_to_deg.py
+++ b/mathgenerator/funcs/radian_to_deg.py
@@ -14,5 +14,5 @@ def radianToDegFunc(max_rad=3):
return problem, solution
-radian_to_deg = Generator("Radians to Degrees", 87,
- "Angle a in degrees is = ", "b", radianToDegFunc)
+radian_to_deg = Generator("Radians to Degrees", 87, "Angle a in degrees is = ",
+ "b", radianToDegFunc)
diff --git a/mathgenerator/funcs/sector_area.py b/mathgenerator/funcs/sector_area.py
index 9a14728..12692fb 100644
--- a/mathgenerator/funcs/sector_area.py
+++ b/mathgenerator/funcs/sector_area.py
@@ -12,5 +12,5 @@ def sectorAreaFunc(maxRadius=49, maxAngle=359):
sector_area = Generator("Area of a Sector", 75,
- "Area of a sector with radius, r and angle, a ", "Area",
- sectorAreaFunc)
+ "Area of a sector with radius, r and angle, a ",
+ "Area", sectorAreaFunc)
diff --git a/mathgenerator/funcs/set_operation.py b/mathgenerator/funcs/set_operation.py
new file mode 100644
index 0000000..263b548
--- /dev/null
+++ b/mathgenerator/funcs/set_operation.py
@@ -0,0 +1,27 @@
+from .__init__ import *
+
+
+def set_operation(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):
+ a.append(random.randint(1, 10))
+ for i 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))
+ return problem, solution
+
+
+set_operation = Generator("Union,Intersection,Difference of Two Sets", 93,
+ "Union,intersection,difference", "aUb,a^b,a-b,b-a,",
+ set_operation)
diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py
index 2a969fa..1a09015 100644
--- a/mathgenerator/mathgen.py
+++ b/mathgenerator/mathgen.py
@@ -1,7 +1,6 @@
from .funcs import *
from .__init__ import getGenList
-
genList = getGenList()
diff --git a/setup.py b/setup.py
index 4bfbcd0..23e337e 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,12 @@
from setuptools import setup, find_packages
setup(name='mathgenerator',
- version='1.1.3',
+ version='1.1.4',
description='An open source solution for generating math problems',
url='https://github.com/todarith/mathgenerator',
author='Luke Weiler',
author_email='lukew25073@gmail.com',
license='MIT',
packages=find_packages(),
- install_requires=[],
+ install_requires=['sympy', 'numpy', 'scipy'],
entry_points={})
diff --git a/test.py b/test.py
index 74d73ce..f331968 100644
--- a/test.py
+++ b/test.py
@@ -10,4 +10,4 @@ for item in list:
print(item[2])
# print(mathgen.getGenList())
-print(mathgen.genById(89))
+print(mathgen.genById(99))