mathgenerator
A math problem generator, created for the purpose of giving self-studying students and teaching organizations the means to easily get access to random math problems to suit their needs.
To try out generators, go to https://todarith.ml/generate/
If you have an idea for a generator, please add it as an issue and tag it with the "New Generator" label.
Table of Contents
Installation
The project can be install via pip
pip install mathgenerator
Basic Usage
Here is an example of how you would generate an addition problem:
from mathgenerator import mathgen
#generate an addition problem
problem, solution = mathgen.addition()
#another way to generate an addition problem using genById()
problem, solution = mathgen.genById(0)
Documentation
getGenList() returns a list of all generators in the repository in the format [id, title, self, funcname]
genById(id) generates a problem, solution set with generator id id in the form of a list in the format [problem, solution]
make_pdf(id, count) creates a printable pdf worksheet with count problems generated by the generator with id id.
More complicated worksheets
import sys
from mathgenerator import mathgen
worksheet = mathgen.make_worksheet("2020-11-29")
mathgen.add_section_with_task_to_worksheet(worksheet, 105, 5)
mathgen.add_section_with_task_to_worksheet(worksheet, 2, 5)
mathgen.write_pdf(worksheet)
List of Generators
algebra
| Id | Skill | Example problem | Example Solution | Function Name | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 11 | Basic Algebra | 1x + 7 = 8 | 1 | basic_algebra | ||||||||||||||||||||||||||||||||
| 12 | Logarithm | log3(243) | 5 | log | ||||||||||||||||||||||||||||||||
| 17 | Integer Multiplication with 2x2 Matrix | 1 * 1, 10], [4, 7 = | 1,10],[4,7 | multiply_int_to_22_matrix | ||||||||||||||||||||||||||||||||
| 20 | Midpoint of the two point | (2,2),(9,-20)= | (5.5,-9.0) | midpoint_of_two_points | ||||||||||||||||||||||||||||||||
| 21 | Factoring Quadratic | x^2-11x+30 | (x-5)(x-6) | factoring | ||||||||||||||||||||||||||||||||
| 23 | Solve a System of Equations in R^2 | 5x - 2y = -22, x + 3y = 16 | x = -2, y = 6 | system_of_equations | ||||||||||||||||||||||||||||||||
| 24 | Distance between 2 points | Find the distance between (1, 17) and (3, -13) | sqrt(904) | distance_two_points | ||||||||||||||||||||||||||||||||
| 26 | Linear Equations | 11x + 1y = 110, 20x + 14y = 200 | x = 10, y = 0 | linear_equations | ||||||||||||||||||||||||||||||||
| 41 | Intersection of Two Lines | Find the point of intersection of the two lines: y = 9/5x - 10 and y = -2/3x + 4 | (210/37, 8/37) | intersection_of_two_lines | ||||||||||||||||||||||||||||||||
| 43 | Cross Product of 2 Vectors | [3, -13, -15] X [-7, -17, -2] = | [-229, 111, -142] | vector_cross | ||||||||||||||||||||||||||||||||
| 45 | Simple Interest | Simple interest for a principle amount of 5720 dollars, 1% rate of interest and for a time period of 6 years is = | 343.2 | simple_interest | ||||||||||||||||||||||||||||||||
| 46 | Multiplication of two matrices | Multiply
|
|
matrix_multiplication | ||||||||||||||||||||||||||||||||
| 50 | Quadratic Equation | Zeros of the Quadratic Equation 95x^2+151x+54=0 | [-0.54, -1.05] | quadratic_equation | ||||||||||||||||||||||||||||||||
| 65 | Multiplication of 2 complex numbers | (-16+18j) * (20-9j) = | (-158+504j) | multiply_complex_numbers | ||||||||||||||||||||||||||||||||
| 72 | Dot Product of 2 Vectors | [-8, 19, -7] . [13, 12, 16] = | 12 | vector_dot | ||||||||||||||||||||||||||||||||
| 74 | Inverse of a Matrix | Inverse of Matrix Matrix(23, 40, 67], [72, 41, 63], [71, 75, 27) is: | Matrix(-3618/184709, 3945/184709, -227/184709], [2529/184709, -4136/184709, 3375/184709], [2489/184709, 1115/184709, -1937/184709) | invert_matrix | ||||||||||||||||||||||||||||||||
| 77 | Determinant to 2x2 Matrix | Det(92, 39], [87, 30) = | -633 | int_matrix_22_determinant | ||||||||||||||||||||||||||||||||
| 78 | Compound Interest | Compound interest for a principle amount of 3384 dollars, 10% rate of interest and for a time period of 5 year is = | 5449.97 | compound_interest | ||||||||||||||||||||||||||||||||
| 100 | complex Quadratic Equation | Find the roots of given Quadratic Equation 2x^2 + 6x + 3 = 0 | simplified solution : ((-0.634, -2.366)), generalized solution : ((-6 + sqrt(12))/22, (-6 - sqrt(12))/22) | complex_quadratic | ||||||||||||||||||||||||||||||||
| 105 | Combine Like terms | 2x^3 + 2x^2 + 9x^2 + 10x^2 + 1x^4 | 21x^2 + 2x^3 + 1x^4 | combine_like_terms | ||||||||||||||||||||||||||||||||
| 111 | Expanding Factored Binomial | (2x-5)(+4x-2) | 8x^2-24x+10 | expanding |
basic_math
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 0 | Addition | 46+18= | 64 | addition |
| 1 | Subtraction | 46-35= | 11 | subtraction |
| 2 | Multiplication | 38*0= | 0 | multiplication |
| 3 | Division | 192/16= | 12 | division |
| 6 | Square Root | sqrt(16)= | 4 | square_root |
| 8 | Square | 4^2= | 16 | square |
| 13 | Complex Division | 26/40= | 0.65 | complex_division |
| 16 | Fraction Division | (4/3)/(8/10) | 5/3 | divide_fractions |
| 28 | Fraction Multiplication | (7/3)*(2/5) | 14/15 | fraction_multiplication |
| 31 | Factorial | 3! = | 6 | factorial |
| 44 | Compare Fractions | Which symbol represents the comparison between 4/5 and 7/1? | < | compare_fractions |
| 47 | Cube Root | cuberoot of 718 upto 2 decimal places is: | 8.95 | cube_root |
| 53 | Exponentiation | 17^6 = | 24137569 | exponentiation |
| 71 | Absolute difference between two numbers | Absolute difference between numbers -27 and 96 = | 123 | absolute_difference |
| 80 | Percentage of a number | What is 55% of 82? | Required percentage = 45.10% | percentage |
| 90 | isprime | 61 | True | is_prime |
| 97 | Power of Powers | The 42^1^2 = 42^(1*2) = 42^2 | 1764 | power_of_powers |
calculus
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 7 | Power Rule Differentiation | 1x^2 + 3x^5 + 6x^7 | 2x^1 + 15x^4 + 42x^6 | power_rule_differentiation |
| 48 | Power Rule Integration | 9x^1 + 10x^4 + 5x^6 | (9/1)x^2 + (10/4)x^5 + (5/6)x^7 + c | power_rule_integration |
| 88 | Differentiation | differentiate w.r.t x : d(tan(x)+5*x^(-2))/dx | tan(x)^2 + 1 - 10/x^3 | differentiation |
| 89 | Definite Integral of Quadratic Equation | The definite integral within limits 0 to 1 of the equation 20x^2 + 27x + 41 is = | 61.1667 | definite_integral |
| 110 | Stationary Points | f(x)=7x^3 + 2x^2 + 6 | (-4/21,7970/1323),(0,6) | stationary_points |
computer_science
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 4 | Binary Complement 1s | 00011= | 11100 | binary_complement_1s |
| 5 | Modulo Division | 0%10= | 0 | modulo_division |
| 14 | Decimal to Binary | Binary of 62= | 111110 | decimal_to_binary |
| 15 | Binary to Decimal | 0101101 | 45 | binary_to_decimal |
| 56 | Fibonacci Series | The Fibonacci Series of the first 13 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144] | fibonacci_series |
| 62 | nth Fibonacci number | What is the 63th Fibonacci number? | 6557470319842 | nth_fibonacci_number |
| 64 | Binary to Hexidecimal | 110010100 | 0x194 | binary_to_hex |
| 73 | Binary 2's Complement | 2's complement of 10 = | 10 | binary_2s_complement |
| 79 | Decimal to Hexadecimal | Binary of 797= | 0x31d | decimal_to_hexadeci |
| 84 | Converts decimal to octal | The decimal number 3704 in Octal is: | 0o7170 | decimal_to_octal |
| 91 | Binary Coded Decimal to Integer | Integer of Binary Coded Decimal 7 is = | 30104 | bcd_to_decimal |
| 103 | Decimal to Binary Coded Decimal | BCD of Decimal Number 2037 is = | 7155 | decimal_to_bcd |
geometry
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 18 | Area of Triangle | Area of triangle with side lengths: 7 4 7 = | 13.416407864998739 | area_of_triangle |
| 19 | Triangle exists check | Does triangle with sides 7, 31 and 16 exist? | No | valid_triangle |
| 22 | Third Angle of Triangle | Third angle of triangle with angles 73 and 76 = | 31 | third_angle_of_triangle |
| 25 | Pythagorean Theorem | The hypotenuse of a right triangle given the other two lengths 16 and 5 = | 16.76 | pythagorean_theorem |
| 29 | Angle of a Regular Polygon | Find the angle of a regular polygon with 12 sides | 150.0 | angle_regular_polygon |
| 32 | Surface Area of Cube | Surface area of cube with side = 1m is | 6 m^2 | surface_area_cube |
| 33 | Surface Area of Cuboid | Surface area of cuboid with sides = 1m, 18m, 12m is | 492 m^2 | surface_area_cuboid |
| 34 | Surface Area of Cylinder | Surface area of cylinder with height = 11m and radius = 17m is | 2990 m^2 | surface_area_cylinder |
| 35 | Volum of Cube | Volume of cube with side = 5m is | 125 m^3 | volume_cube |
| 36 | Volume of Cuboid | Volume of cuboid with sides = 16m, 18m, 10m is | 2880 m^3 | volume_cuboid |
| 37 | Volume of cylinder | Volume of cylinder with height = 13m and radius = 4m is | 653 m^3 | volume_cylinder |
| 38 | Surface Area of cone | Surface area of cone with height = 30m and radius = 16m is | 2513 m^2 | surface_area_cone |
| 39 | Volume of cone | Volume of cone with height = 14m and radius = 20m is | 5864 m^3 | volume_cone |
| 49 | Fourth Angle of Quadrilateral | Fourth angle of quadrilateral with angles 25 , 183, 109 = | 43 | fourth_angle_of_quadrilateral |
| 57 | Trigonometric Values | What is sin(30)? | 1/2 | basic_trigonometry |
| 58 | Sum of Angles of Polygon | Sum of angles of polygon with 12 sides = | 1800 | sum_of_polygon_angles |
| 60 | Surface Area of Sphere | Surface area of Sphere with radius = 10m is | 1256.6370614359173 m^2 | surface_area_sphere |
| 61 | Volume of Sphere | Volume of sphere with radius 61 m = | 950775.7894726198 m^3 | volume_sphere |
| 70 | Angle between 2 vectors | angle between the vectors [437.0, 613.71, 778.37, 977.11, 617.14, 527.38, 196.94, 993.88, 186.86, 937.36, 323.15, 896.54, 646.74] and [753.99, 971.66, 175.71, 81.48, 178.5, 671.53, 624.94, 662.16, 533.37, 974.47, 598.63, 690.91, 743.68] is: | 0.62 radians | angle_btw_vectors |
| 75 | Area of a Sector | Given radius, 2 and angle, 324. Find the area of the sector. | Area of sector = 11.30973 | sector_area |
| 86 | Degrees to Radians | Angle 47 in radians is = | 0.82 | degree_to_rad |
| 87 | Radians to Degrees | Angle 0 in degrees is = | 0.0 | radian_to_deg |
| 95 | Curved surface area of a cylinder | What is the curved surface area of a cylinder of radius, 19 and height, 88? | CSA of cylinder = 10505.49 | curved_surface_area_cylinder |
| 96 | Perimeter of Polygons | The perimeter of a 3 sided polygon with lengths of [27, 98, 14]cm is: | 139 | perimeter_of_polygons |
| 104 | Circumference | Circumference of circle with radius 90 | 565.4866776461628 | circumference |
| 108 | Arc length of Angle | Given radius, 2 and angle, 37. Find the arc length of the angle. | Arc length of the angle = 1.29154 | arc_length |
| 112 | Area of Circle | Area of circle with radius 0 | 0.0 | area_of_circle |
misc
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 9 | LCM (Least Common Multiple) | LCM of 16 and 10 = | 80 | lcm |
| 10 | GCD (Greatest Common Denominator) | GCD of 13 and 1 = | 1 | gcd |
| 27 | Prime Factorisation | Find prime factors of 11 | [11] | prime_factors |
| 40 | Common Factors | Common Factors of 65 and 19 = | [1] | common_factors |
| 51 | HCF (Highest Common Factor) | HCF of 20 and 14 = | 2 | hcf |
| 55 | Comparing surds | Fill in the blanks 78^(1/7) _ 52^(1/9) | > | surds_comparison |
| 63 | Profit or Loss Percent | Loss percent when CP = 431 and SP = 150 is: | 65.19721577726219 | profit_loss_percent |
| 66 | Geometric Progression | For the given GP [3, 12, 48, 192, 768, 3072] ,Find the value of a,common ratio,11th term value, sum upto 11th term | The value of a is 3, common ratio is 4 , 11th term is 3145728 , sum upto 11th term is 4194303.0 | geometric_progression |
| 67 | Geometric Mean of N Numbers | Geometric mean of 4 numbers 40 , 63 , 65 , 24 = | (406365*24)^(1/4) = 44.52780476312522 | geometric_mean |
| 68 | Harmonic Mean of N Numbers | Harmonic mean of 4 numbers 48 , 59 , 75 , 80 = | 4/((1/48) + (1/59) + (1/75) + (1/80)) = 62.87744227353463 | harmonic_mean |
| 69 | Euclidian norm or L2 norm of a vector | Euclidian norm or L2 norm of the vector[249.0015460376116, 867.8122114074212, 4.2765473742734095, 450.4653172064377, 435.0307355906793, 628.6207356296137, 313.9369656743921, 290.1828788563886, 716.1780160982277, 29.88164461825127] is: | 1516.2517107189344 | euclidian_norm |
| 81 | Celsius To Fahrenheit | Convert 22 degrees Celsius to degrees Fahrenheit = | 71.6 | celsius_to_fahrenheit |
| 82 | AP Term Calculation | Find the term number 93 of the AP series: 54, 33, 12 ... | -1878 | arithmetic_progression_term |
| 83 | AP Sum Calculation | Find the sum of first 21 terms of the AP series: -96, -65, -34 ... | 4494.0 | arithmetic_progression_sum |
| 85 | Converts decimal to Roman Numerals | The number 3999 in Roman Numerals is: | MMMCMXCIX | decimal_to_roman_numerals |
| 92 | Complex To Polar Form | rexp(itheta) = | 13.04exp(i-3.06) | complex_to_polar |
| 93 | Union,Intersection,Difference of Two Sets | Given the two sets a={8, 10, 3, 5} ,b={1, 3, 6}.Find the Union,intersection,a-b,b-a and symmetric difference | Union is {1, 3, 5, 6, 8, 10},Intersection is {3}, a-b is {8, 10, 5},b-a is {1, 6}, Symmetric difference is {1, 5, 6, 8, 10} | set_operation |
| 94 | Base Conversion | Convert 7959 from base 16 to base 9. | 46546 | base_conversion |
| 98 | Quotient of Powers with Same Base | The Quotient of 40^4 and 40^4 = 40^(4-4) = 40^0 | 1 | quotient_of_power_same_base |
| 99 | Quotient of Powers with Same Power | The Quotient of 26^7 and 33^7 = (26/33)^7 = 0.7878787878787878^7 | 0.1884585549109465 | quotient_of_power_same_power |
| 101 | Leap Year or Not | Year 1975 | is not a leap year | is_leap_year |
| 102 | Minute to Hour conversion | Convert 151 minutes to Hours & Minutes | 2 hours and 31 minutes | minutes_to_hours |
| 106 | signum function | signum of -252 is = | -1 | signum_function |
| 109 | Binomial distribution | A manufacturer of metal pistons finds that, on average, 39.81% of the pistons they manufacture are rejected because they are incorrectly sized. What is the probability that a batch of 15 pistons will contain no more than 5 rejected pistons? | 40.91 | binomial_distribution |
statistics
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 30 | Combinations of Objects | Number of combinations from 11 objects picked 8 at a time | 165 | combinations |
| 42 | Permutations | Number of Permutations from 17 objects picked 1 at a time = | 17 | permutation |
| 52 | Probability of a certain sum appearing on faces of dice | If 3 dice are rolled at the same time, the probability of getting a sum of 14 = | 15/216 | dice_sum_probability |
| 54 | Confidence interval For sample S | The confidence interval for sample [270, 291, 266, 239, 273, 283, 243, 288, 289, 214, 226, 209, 258, 256, 249, 202, 220, 253, 208, 236, 245, 221, 271, 264, 240, 293] with 90% confidence is | (259.0741428605511, 241.46431867791048) | confidence_interval |
| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[46, 25, 24, 23, 49, 22, 17, 8, 24, 28, 37, 31, 31, 23, 8] | The Mean is 26.4 , Standard Deviation is 124.90666666666668, Variance is 11.17616511450447 | data_summary |
| 76 | Mean and Median | Given the series of numbers [21, 85, 4, 40, 42, 50, 69, 75, 91, 71]. find the arithmatic mean and mdian of the series | Arithmetic mean of the series is 54.8 and Arithmetic median of this series is 59.5 | mean_median |
| 107 | Conditional Probability | Someone tested positive for a nasty disease which only 1.68% of population have. Test sensitivity (true positive) is equal to SN= 94.32% whereas test specificity (true negative) SP= 99.09%. What is the probability that this guy really has that disease? | 63.91% | conditional_probability |