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)
More Complicated Usage
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)
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.
List of Generators
algebra
| Id | Skill | Example problem | Example Solution | Function Name | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 11 | Basic Algebra | 5x + 4 = 5 | 1/5 | basic_algebra | ||||||||||||||||
| 12 | Logarithm | log2(128) | 7 | log | ||||||||||||||||
| 17 | Integer Multiplication with 2x2 Matrix | 46 * 1, 1], [0, 2 = | 46,46],[0,92 | multiply_int_to_22_matrix | ||||||||||||||||
| 20 | Midpoint of the two point | (-13,-9),(19,6)= | (3.0,-1.5) | midpoint_of_two_points | ||||||||||||||||
| 21 | Factoring Quadratic | x^2+3x | (x)(x+3) | factoring | ||||||||||||||||
| 23 | Solve a System of Equations in R^2 | - 7y = 70, -3x - 7y = 67 | x = 1, y = -10 | system_of_equations | ||||||||||||||||
| 24 | Distance between 2 points | Find the distance between (13, 19) and (-14, 15) | sqrt(745) | distance_two_points | ||||||||||||||||
| 26 | Linear Equations | 6x + -11y = 226, 12x + -2y = 52 | x = 1, y = -20 | linear_equations | ||||||||||||||||
| 41 | Intersection of Two Lines | Find the point of intersection of the two lines: y = 2/6x + 10 and y = 1/3x + 2 | No Solution | intersection_of_two_lines | ||||||||||||||||
| 43 | Cross Product of 2 Vectors | [20, 2, -1] X [-12, 13, 17] = | [47, -328, 284] | vector_cross | ||||||||||||||||
| 45 | Simple Interest | Simple interest for a principle amount of 9811 dollars, 10% rate of interest and for a time period of 2 years is = | 1962.2 | simple_interest | ||||||||||||||||
| 46 | Multiplication of two matrices | Multiply
|
|
matrix_multiplication | ||||||||||||||||
| 50 | Quadratic Equation | Zeros of the Quadratic Equation 82x^2+62x+5=0 | [-0.09, -0.66] | quadratic_equation | ||||||||||||||||
| 65 | Multiplication of 2 complex numbers | (-20+16j) * (3+5j) = | (-140-52j) | multiply_complex_numbers | ||||||||||||||||
| 72 | Dot Product of 2 Vectors | [-1, -6, 17] . [-3, -8, -13] = | -170 | vector_dot | ||||||||||||||||
| 74 | Inverse of a Matrix | Inverse of Matrix Matrix(99, 2, 35], [65, 17, 23], [73, 12, 26) is: | Matrix(166/277, 368/277, -549/277], [-11/277, 19/277, -2/277], [-461/277, -1042/277, 1553/277) | invert_matrix | ||||||||||||||||
| 77 | Determinant to 2x2 Matrix | Det(29, 80], [90, 24) = | -6504 | int_matrix_22_determinant | ||||||||||||||||
| 78 | Compound Interest | Compound interest for a principle amount of 2613 dollars, 7% rate of interest and for a time period of 9 year is = | 4803.89 | compound_interest | ||||||||||||||||
| 100 | complex Quadratic Equation | Find the roots of given Quadratic Equation 2x^2 + 9x + 9 = 0 | simplified solution : ((-1.5, -3.0)), generalized solution : ((-9 + 3)/22, (-9 - 3)/22) | complex_quadratic | ||||||||||||||||
| 105 | Combine Like terms | 8x^2 + 4x^1 + 5x^2 | 4x^1 + 13x^2 | combine_like_terms | ||||||||||||||||
| 111 | Expanding Factored Binomial | (3x+3)(-2x-5) | -6x^2-21x-15 | expanding |
basic_math
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 0 | Addition | 20+10= | 30 | addition |
| 1 | Subtraction | 3-1= | 2 | subtraction |
| 2 | Multiplication | 83*0= | 0 | multiplication |
| 3 | Division | 40/5= | 8 | division |
| 6 | Square Root | sqrt(144)= | 12 | square_root |
| 8 | Square | 1^2= | 1 | square |
| 13 | Complex Division | 95/42= | 2.26 | complex_division |
| 16 | Fraction Division | (5/3)/(3/2) | 10/9 | divide_fractions |
| 28 | Fraction Multiplication | (4/6)*(3/1) | 2 | fraction_multiplication |
| 31 | Factorial | 4! = | 24 | factorial |
| 44 | Compare Fractions | Which symbol represents the comparison between 9/4 and 9/10? | > | compare_fractions |
| 47 | Cube Root | cuberoot of 561 upto 2 decimal places is: | 8.25 | cube_root |
| 53 | Exponentiation | 15^10 = | 576650390625 | exponentiation |
| 71 | Absolute difference between two numbers | Absolute difference between numbers 88 and -62 = | 150 | absolute_difference |
| 80 | Percentage of a number | What is 68% of 22? | Required percentage = 14.96% | percentage |
| 90 | isprime | 73 | True | is_prime |
| 97 | Power of Powers | The 10^3^6 = | 10^18 | power_of_powers |
calculus
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 7 | Power Rule Differentiation | 6x^2 + 8x^3 + 4x^1 + 10x^7 + 3x^4 | 12x^1 + 24x^2 + 4x^0 + 70x^6 + 12x^3 | power_rule_differentiation |
| 48 | Power Rule Integration | 7x^7 + 1x^3 + 3x^1 | (7/7)x^8 + (1/3)x^4 + (3/1)x^2 + c | power_rule_integration |
| 88 | Differentiation | differentiate w.r.t x : d(exp(x)+8*x^(-4))/dx | exp(x) - 32/x^5 | differentiation |
| 89 | Definite Integral of Quadratic Equation | The definite integral within limits 0 to 1 of the equation 92x^2 + 62x + 64 is = | 125.6667 | definite_integral |
| 110 | Stationary Points | f(x)=7x^3 + 6x^2 + x + 4 | (-2/7 - sqrt(15)/21,7*(-2/7 - sqrt(15)/21)*3 - sqrt(15)/21 + 6(-2/7 - sqrt(15)/21)*2 + 26/7),(-2/7 + sqrt(15)/21,7(-2/7 + sqrt(15)/21)*3 + 6(-2/7 + sqrt(15)/21)**2 + sqrt(15)/21 + 26/7) | stationary_points |
computer_science
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 4 | Binary Complement 1s | 101= | 010 | binary_complement_1s |
| 5 | Modulo Division | 49%4= | 1 | modulo_division |
| 14 | Decimal to Binary | Binary of 1= | 1 | decimal_to_binary |
| 15 | Binary to Decimal | 001010010 | 82 | binary_to_decimal |
| 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 |
| 62 | nth Fibonacci number | What is the 88th Fibonacci number? | 1100087778366105088 | nth_fibonacci_number |
| 64 | Binary to Hexidecimal | 01100001 | 0x61 | binary_to_hex |
| 73 | Binary 2's Complement | 2's complement of 111 = | 1 | binary_2s_complement |
| 79 | Decimal to Hexadecimal | Binary of 971= | 0x3cb | decimal_to_hexadeci |
| 84 | Converts decimal to octal | The decimal number 2071 in Octal is: | 0o4027 | decimal_to_octal |
| 91 | Binary Coded Decimal to Integer | Integer of Binary Coded Decimal 8 is = | 33632 | bcd_to_decimal |
| 103 | Decimal to Binary Coded Decimal | BCD of Decimal Number 3705 is = | 1479 | decimal_to_bcd |
geometry
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 18 | Area of Triangle | Area of triangle with side lengths: 3 2 1 = | 0.0 | area_of_triangle |
| 19 | Triangle exists check | Does triangle with sides 28, 3 and 46 exist? | No | valid_triangle |
| 22 | Third Angle of Triangle | Third angle of triangle with angles 39 and 26 = | 115 | third_angle_of_triangle |
| 25 | Pythagorean Theorem | The hypotenuse of a right triangle given the other two lengths 15 and 2 = | 15.13 | pythagorean_theorem |
| 29 | Angle of a Regular Polygon | Find the angle of a regular polygon with 15 sides | 156.0 | angle_regular_polygon |
| 32 | Surface Area of Cube | Surface area of cube with side = 19m is | 2166 m^2 | surface_area_cube |
| 33 | Surface Area of Cuboid | Surface area of cuboid with sides = 12m, 11m, 8m is | 632 m^2 | surface_area_cuboid |
| 34 | Surface Area of Cylinder | Surface area of cylinder with height = 24m and radius = 20m is | 5529 m^2 | surface_area_cylinder |
| 35 | Volum of Cube | Volume of cube with side = 17m is | 4913 m^3 | volume_cube |
| 36 | Volume of Cuboid | Volume of cuboid with sides = 20m, 16m, 12m is | 3840 m^3 | volume_cuboid |
| 37 | Volume of cylinder | Volume of cylinder with height = 22m and radius = 5m is | 1727 m^3 | volume_cylinder |
| 38 | Surface Area of cone | Surface area of cone with height = 15m and radius = 17m is | 2118 m^2 | surface_area_cone |
| 39 | Volume of cone | Volume of cone with height = 47m and radius = 15m is | 11074 m^3 | volume_cone |
| 49 | Fourth Angle of Quadrilateral | Fourth angle of quadrilateral with angles 89 , 113, 45 = | 113 | 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 4 sides = | 360 | sum_of_polygon_angles |
| 60 | Surface Area of Sphere | Surface area of Sphere with radius = 15m is | 2827.4333882308138 m^2 | surface_area_sphere |
| 61 | Volume of Sphere | Volume of sphere with radius 48 m = | 463246.68632773653 m^3 | volume_sphere |
| 70 | Angle between 2 vectors | angle between the vectors [944.71, 489.17, 672.42, 273.44, 322.14, 518.37, 40.41, 702.81, 693.13, 735.38, 118.6, 162.04] and [492.38, 958.81, 864.23, 371.52, 766.01, 529.63, 684.23, 381.09, 354.22, 812.68, 455.91, 304.03] is: | 0.59 radians | angle_btw_vectors |
| 75 | Area of a Sector | Given radius, 20 and angle, 244. Find the area of the sector. | Area of sector = 851.72067 | sector_area |
| 86 | Degrees to Radians | Angle 278 in radians is = | 4.85 | 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, 32 and height, 85? | CSA of cylinder = 17090.26 | curved_surface_area_cylinder |
| 96 | Perimeter of Polygons | The perimeter of a 9 sided polygon with lengths of [14, 79, 24, 104, 34, 14, 89, 73, 96]cm is: | 527 | perimeter_of_polygons |
| 104 | Circumference | Circumference of circle with radius 42 | 263.89378290154264 | circumference |
| 108 | Arc length of Angle | Given radius, 46 and angle, 48. Find the arc length of the angle. | Arc length of the angle = 38.53687 | arc_length |
| 112 | Area of Circle | Area of circle with radius 99 | 30803.142857142855 | area_of_circle |
misc
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 9 | LCM (Least Common Multiple) | LCM of 6 and 8 = | 24 | lcm |
| 10 | GCD (Greatest Common Denominator) | GCD of 13 and 10 = | 1 | gcd |
| 27 | Prime Factorisation | Find prime factors of 76 | [2, 2, 19] | prime_factors |
| 40 | Common Factors | Common Factors of 67 and 27 = | [1] | common_factors |
| 51 | HCF (Highest Common Factor) | HCF of 5 and 9 = | 1 | hcf |
| 55 | Comparing surds | Fill in the blanks 95^(1/9) _ 72^(1/6) | < | surds_comparison |
| 63 | Profit or Loss Percent | Loss percent when CP = 915 and SP = 429 is: | 53.11475409836065 | profit_loss_percent |
| 66 | Geometric Progression | For the given GP [2, 24, 288, 3456, 41472, 497664] ,Find the value of a,common ratio,7th term value, sum upto 6th term | The value of a is 2, common ratio is 12 , 7th term is 5971968 , sum upto 6th term is 542906.0 | geometric_progression |
| 67 | Geometric Mean of N Numbers | Geometric mean of 4 numbers 12 , 47 , 51 , 68 = | (124751*68)^(1/4) = 37.39723971741515 | geometric_mean |
| 68 | Harmonic Mean of N Numbers | Harmonic mean of 3 numbers 7 , 99 and 16 = | 3/((1/7) + (1/99) + (1/16)) = 13.923817496860611 | harmonic_mean |
| 69 | Euclidian norm or L2 norm of a vector | Euclidian norm or L2 norm of the vector[691.8561789598966, 354.4150198199495, 732.2953785710989] is: | 1067.9566939326487 | euclidian_norm |
| 81 | Celsius To Fahrenheit | Convert 41 degrees Celsius to degrees Fahrenheit = | 105.8 | celsius_to_fahrenheit |
| 82 | AP Term Calculation | Find the term number 90 of the AP series: -3, -46, -89 ... | -3830 | arithmetic_progression_term |
| 83 | AP Sum Calculation | Find the sum of first 19 terms of the AP series: 26, -21, -68 ... | -7543.0 | arithmetic_progression_sum |
| 85 | Converts decimal to Roman Numerals | The number 2018 in Roman Numerals is: | MMXVIII | decimal_to_roman_numerals |
| 92 | Complex To Polar Form | rexp(itheta) = | 20.88exp(i-0.29) | complex_to_polar |
| 93 | Union,Intersection,Difference of Two Sets | Given the two sets a={1, 10} ,b={9, 6, 7}.Find the Union,intersection,a-b,b-a and symmetric difference | Union is {1, 6, 7, 9, 10},Intersection is set(), a-b is {1, 10},b-a is {9, 6, 7}, Symmetric difference is {1, 6, 7, 9, 10} | set_operation |
| 94 | Base Conversion | Convert 52287 from base 10 to base 4. | 30300333 | base_conversion |
| 98 | Quotient of Powers with Same Base | The Quotient of 30^9 and 30^1 = 30^(9-1) = 30^8 | 656100000000 | quotient_of_power_same_base |
| 99 | Quotient of Powers with Same Power | The Quotient of 38^7 and 39^7 = (38/39)^7 = 0.9743589743589743^7 | 0.8337443946587956 | quotient_of_power_same_power |
| 101 | Leap Year or Not | Year 2063 | is not a leap year | is_leap_year |
| 102 | Minute to Hour conversion | Convert 407 minutes to Hours & Minutes | 6 hours and 47 minutes | minutes_to_hours |
| 106 | signum function | signum of -619 is = | -1 | signum_function |
| 109 | Binomial distribution | A manufacturer of metal pistons finds that, on average, 32.88% 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 6 rejected pistons? | 98.18 | binomial_distribution |
statistics
| Id | Skill | Example problem | Example Solution | Function Name |
|---|---|---|---|---|
| 30 | Combinations of Objects | Number of combinations from 17 objects picked 9 at a time | 24310 | combinations |
| 42 | Permutations | Number of Permutations from 20 objects picked 3 at a time = | 6840 | 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 7 = | 15/216 | dice_sum_probability |
| 54 | Confidence interval For sample S | The confidence interval for sample [273, 282, 236, 257, 203, 213, 245, 253, 262, 220, 249, 244, 215, 274, 294, 255, 243, 291, 298, 221, 259, 258, 211, 205, 270, 217, 289, 223, 239, 297, 247, 242, 202] with 99% confidence is | (260.95190677733586, 235.22991140448232) | confidence_interval |
| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[6, 43, 17, 14, 23, 24, 19, 49, 35, 6, 23, 25, 20, 24, 48] | The Mean is 25.066666666666666 , Standard Deviation is 167.1288888888889, Variance is 12.927833882321078 | data_summary |
| 76 | Mean and Median | Given the series of numbers [38, 14, 69, 4, 79, 68, 76, 9, 74, 60]. find the arithmatic mean and mdian of the series | Arithmetic mean of the series is 49.1 and Arithmetic median of this series is 64.0 | mean_median |
| 107 | Conditional Probability | Someone tested positive for a nasty disease which only 1.83% of population have. Test sensitivity (true positive) is equal to SN= 96.74% whereas test specificity (true negative) SP= 96.18%. What is the probability that this guy really has that disease? | 32.07% | conditional_probability |