Skip to content

Repository files navigation

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://lukew3.github.io/mathgenerator

See CONTRIBUTING.md for information about how to contribute.

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:

frommathgeneratorimportmathgen#generate an addition problemproblem, solution=mathgen.addition()
#another way to generate an addition problem using genById()problem, solution=mathgen.genById(0)

Creating a worksheet

If you wish to create a worksheet, you can use the worksheetgen package. Install this with pip install worksheetgen. Here is an example of how a worksheet would be generated.

from mathgenerator import mathgen
from worksheetgen.wg import Worksheet
worksheet = Worksheet("Worksheet title")
worksheet.add_instruction("Instructions")
# Writes 10 problems generated with id 1, [0] at the end specifies to take problem, and not solution.
for _ in range(10):
worksheet.add_problem(mathgen.genById(1)[0])
worksheet.write_pdf()

This creates the pdf ws.pdf in your current directory

Documentation

  • getGenList() returns a list of all generators in the repository in the format [id, title, self, funcname, subjectname]

  • genById(id) generates a problem, solution set with generator id id in the format [problem, solution]

  • Pass the kwarg format=latex to return problem and solution set as latex. If latex is not available for that generator, the problem will return the string "Latex unavailable"

  • Pass the kwarg format=raw to return just the raw data for each generator. An array of each variable necessary to the generator is returned.

List of Generators

algebra

IdSkillExample problemExample SolutionFunction NameKwargs
11Basic Algebra5x + 10 = 100basic_algebramaxVariable=10
12Logarithmlog3(6561)8logmaxBase=3maxVal=8
17Integer Multiplication with 2x2 Matrix8 * [[3, 2], [7, 2]] =[[24,16],[56,16]]multiply_int_to_22_matrixmaxMatrixVal=10maxRes=100
20Midpoint of the two point(20,9),(19,-14)=(19.5,-2.5)midpoint_of_two_pointsmaxValue=20
21Factoring Quadraticx^2+8x(x)(x+8)factoringrange_x1=10range_x2=10
23Solve a System of Equations in R^2-7x + 3y = 27, -7x - 6y = 72x = -6, y = -5system_of_equationsrange_x=10range_y=10coeff_mult_range=10
24Distance between 2 pointsFind the distance between (2, -17) and (-3, 3)sqrt(425)distance_two_pointsmaxValXY=20minValXY=-20
26Linear Equations8x + -9y = 284, -1x + 8y = -173x = 13, y = -20linear_equationsn=2varRange=20coeffRange=20
41Intersection of Two LinesFind the point of intersection of the two lines: y = -6/2x - 1 and y = -4/4x + 9(-5, 14)intersection_of_two_linesminM=-10maxM=10minB=-10maxB=10minDenominator=1maxDenominator=6
43Cross Product of 2 Vectors[14, -13, 12] X [-19, -17, 13] =[35, -410, -485]vector_crossminVal=-20maxVal=20
45Simple InterestSimple interest for a principle amount of 8091 dollars, 10% rate of interest and for a time period of 7 years is =5663.7simple_interestmaxPrinciple=10000maxRate=10maxTime=10
46Multiplication of two matricesMultiply
-17-8-4
8-9-25
and
923
-55-10
54-6
3-33
-9613-37
122-52141
matrix_multiplicationmaxVal=100max_dim=10
50Quadratic EquationZeros of the Quadratic Equation 7x^2+122x+94=0[-0.81, -16.62]quadratic_equationmaxVal=100
65Multiplication of 2 complex numbers(-16+20j) * (17+4j) =(-352+276j)multiply_complex_numbersminRealImaginaryNum=-20maxRealImaginaryNum=20
72Dot Product of 2 Vectors[4, -3, -16] . [3, 13, 0] =-27vector_dotminVal=-20maxVal=20
74Inverse of a MatrixInverse of Matrix Matrix([[41, 99, 20], [79, 6, 68], [18, 53, 66]]) is:Matrix([[1604/222479, 7/569, -3306/222479], [1995/222479, -3/569, 604/222479], [-4079/444958, 1/1138, 7575/444958]])invert_matrixSquareMatrixDimension=3MaxMatrixElement=99OnlyIntegerElementsInInvertedMatrix=False
77Determinant to 2x2 MatrixDet([[96, 4], [87, 48]]) =4260int_matrix_22_determinantmaxMatrixVal=100
78Compound InterestCompound interest for a principle amount of 2136 dollars, 10% rate of interest and for a time period of 6 year is =3784.05compound_interestmaxPrinciple=10000maxRate=10maxTime=10
100complex Quadratic EquationFind the roots of given Quadratic Equation 4x^2 + 4x + 1 = 0simplified solution : ((-0.5, -0.5)), generalized solution : ((-4 + 0)/24, (-4 - 0)/24)complex_quadraticprob_type=0max_range=10
105Combine Like terms9x^2 + 10x^6 + 6x^1 + 2x^5 + 1x^2 + 4x^5 + 3x^46x^1 + 10x^2 + 3x^4 + 6x^5 + 10x^6combine_like_termsmaxCoef=10maxExp=20maxTerms=10
111Expanding Factored Binomial(-3x+10)(+6x-2)-18x^2+66x-20expandingrange_x1=10range_x2=10range_a=10range_b=10

basic_math

IdSkillExample problemExample SolutionFunction NameKwargs
0Addition6+27=33additionmaxSum=99maxAddend=50
1Subtraction32-7=25subtractionmaxMinuend=99maxDiff=99
2Multiplication7*6=42multiplicationmaxMulti=12
3Division40/4=10divisionmaxA=25maxB=25
6Square Rootsqrt(64)=8square_rootminNo=1maxNo=12
8Square6^2=36squaremaxSquareNum=20
13Complex Division13/81=0.16complex_divisionmaxRes=99maxDivid=99
16Fraction Division(3/10)/(3/10)1divide_fractionsmaxVal=10
28Fraction Multiplication(6/2)*(5/4)15/4fraction_multiplicationmaxVal=10
31Factorial4! =24factorialmaxInput=6
44Compare FractionsWhich symbol represents the comparison between 2/10 and 9/6?<compare_fractionsmaxVal=10
47Cube RootWhat is the cube root of 356 up to 2 decimal places?7.09cube_rootminNo=1maxNo=1000
53Exponentiation6^5 =7776exponentiationmaxBase=20maxExpo=10
71Absolute difference between two numbers87-65=22
80Percentage of a numberWhat is 9% of 74?6.66percentagemaxValue=99maxpercentage=99
90isprimeIs 52 prime?Nois_primemax_num=100
97Power of PowersSimplify 15^6^10=15^60power_of_powersmaxBase=50maxPower=10
118Percentage differenceWhat is the percentage difference between 111 and 173?43.66%percentage_differencemaxValue=200minValue=0
119Percentage errorFind the percentage error when observed value equals -64 and exact value equals -14.357.14%percentage_errormaxValue=100minValue=-100
120Greatest Common Divisor of N NumbersGCD(326471423,856701641)=1greatest_common_divisornumbersCount=2maximalNumberLimit=10**9

calculus

IdSkillExample problemExample SolutionFunction NameKwargs
7Power Rule Differentiation7x^7 + 3x^7 + 9x^6 + 6x^149x^6 + 21x^6 + 54x^5 + 6x^0power_rule_differentiationmaxCoef=10maxExp=10maxTerms=5
48Power Rule Integration9x^8(9/8)x^9 + cpower_rule_integrationmaxCoef=10maxExp=10maxTerms=5
88Differentiationdifferentiate w.r.t x : d(sin(x)+9*x^(-2))/dxcos(x) - 18/x^3differentiationdiff_lvl=2
89Definite Integral of Quadratic EquationThe definite integral within limits 0 to 1 of the equation 68x^2 + 64x + 30 is =84.6667definite_integralmax_coeff=100
110Stationary Pointsf(x)=5*x^3 + x^2 + 8(-2/15,5404/675),(0,8)stationary_pointsmaxExp=3maxCoef=10

computer_science

IdSkillExample problemExample SolutionFunction NameKwargs
4Binary Complement 1s1110=0001binary_complement_1smaxDigits=10
5Modulo Division4%90=4modulo_divisionmaxRes=99maxModulo=99
14Decimal to BinaryBinary of 76=1001100decimal_to_binarymax_dec=99
15Binary to Decimal1015binary_to_decimalmax_dig=10
56Fibonacci SeriesThe Fibonacci Series of the first 10 numbers is ?[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]fibonacci_seriesminNo=1
62nth Fibonacci numberWhat is the 80th Fibonacci number?23416728348467744nth_fibonacci_numbermaxN=100
64Binary to Hexidecimal01110110x3bbinary_to_hexmax_dig=10
73Binary 2's Complement2's complement of 111001 =111binary_2s_complementmaxDigits=10
79Decimal to HexadecimalBinary of 162=0xa2decimal_to_hexadecimax_dec=1000
84Converts decimal to octalThe decimal number 1566 in Octal is:0o3036decimal_to_octalmaxDecimal=4096
91Binary Coded Decimal to IntegerInteger of Binary Coded Decimal 8 is =33143bcd_to_decimalmaxNumber=10000
103Decimal to Binary Coded DecimalBCD of Decimal Number 6225 is =1851decimal_to_bcdmaxNumber=10000

geometry

IdSkillExample problemExample SolutionFunction NameKwargs
18Area of TriangleArea of triangle with side lengths: 4 18 17 =33.67area_of_trianglemaxA=20maxB=20
19Triangle exists checkDoes triangle with sides 6, 23 and 24 exist?Yesvalid_trianglemaxSideLength=50
22Third Angle of TriangleThird angle of triangle with angles 23 and 47 =110third_angle_of_trianglemaxAngle=89
25Pythagorean TheoremThe hypotenuse of a right triangle given the other two lengths 6 and 6 =8.49pythagorean_theoremmaxLength=20
29Angle of a Regular PolygonFind the angle of a regular polygon with 8 sides135.0angle_regular_polygonminVal=3maxVal=20
32Surface Area of CubeSurface area of cube with side = 2m is24 m^2surface_area_cubemaxSide=20unit='m'
33Surface Area of CuboidSurface area of cuboid with sides = 19m, 16m, 17m is1798 m^2surface_area_cuboidmaxSide=20unit='m'
34Surface Area of CylinderSurface area of cylinder with height = 19m and radius = 7m is1143 m^2surface_area_cylindermaxRadius=20maxHeight=50unit='m'
35Volum of CubeVolume of cube with side = 2m is8 m^3volume_cubemaxSide=20unit='m'
36Volume of CuboidVolume of cuboid with sides = 13m, 17m, 9m is1989 m^3volume_cuboidmaxSide=20unit='m'
37Volume of cylinderVolume of cylinder with height = 11m and radius = 2m is138 m^3volume_cylindermaxRadius=20maxHeight=50unit='m'
38Surface Area of coneSurface area of cone with height = 31m and radius = 9m is1167 m^2surface_area_conemaxRadius=20maxHeight=50unit='m'
39Volume of coneVolume of cone with height = 10m and radius = 18m is3392 m^3volume_conemaxRadius=20maxHeight=50unit='m'
49Fourth Angle of QuadrilateralFourth angle of quadrilateral with angles 51 , 181, 49 =79fourth_angle_of_quadrilateralmaxAngle=180
57Trigonometric ValuesWhat is tan(90)?basic_trigonometryangles=[0, 30, 45, 60, 90]functions=['sin', 'cos', 'tan']
58Sum of Angles of PolygonSum of angles of polygon with 12 sides =1800sum_of_polygon_anglesmaxSides=12
60Surface Area of SphereSurface area of Sphere with radius = 20m is5026.548245743669 m^2surface_area_spheremaxSide=20unit='m'
61Volume of SphereVolume of sphere with radius 56 m =735618.5806037667 m^3volume_spheremaxRadius=100
70Angle between 2 vectorsangle between the vectors [358.33, 666.13, 650.06, 264.35, 50.1, 338.6, 155.98, 262.18, 470.17, 681.63, 862.29, 561.78, 341.26, 551.94, 484.91, 166.68] and [721.12, 986.28, 667.31, 927.66, 834.74, 48.76, 623.8, 975.84, 466.86, 263.3, 963.54, 653.39, 313.28, 92.3, 218.0, 40.74] is:0.67 radiansangle_btw_vectorsmaxEltAmt=20
75Area of a SectorGiven radius, 39 and angle, 10. Find the area of the sector.Area of sector = 132.73229sector_areamaxRadius=49maxAngle=359
86Degrees to RadiansAngle 227 in radians is =3.96degree_to_radmax_deg=360
87Radians to DegreesAngle 0 in degrees is =0.0radian_to_degmax_rad=3
95Curved surface area of a cylinderWhat is the curved surface area of a cylinder of radius, 10 and height, 21?CSA of cylinder = 1319.47curved_surface_area_cylindermaxRadius=49maxHeight=99
96Perimeter of PolygonsThe perimeter of a 10 sided polygon with lengths of [109, 77, 116, 47, 36, 80, 87, 8, 117, 111]cm is:788perimeter_of_polygonsmaxSides=12maxLength=120
104CircumferenceCircumference of circle with radius 850.26548245743669circumferencemaxRadius=100
108Arc length of AngleGiven radius, 4 and angle, 323. Find the arc length of the angle.Arc length of the angle = 22.54965arc_lengthmaxRadius=49maxAngle=359
112Area of CircleArea of circle with radius 6212081.142857142857area_of_circlemaxRadius=100
113Volume of frustumVolume of frustum with height = 44m and r1 = 19m is and r2 = 19m is29995.0 m^3volume_frustummaxR1=20maxR2=20maxHeight=50unit='m'
114Equation of line from two pointsWhat is the equation of the line between points (-12,4) and (8,0) in slope-intercept form?5y = -x + 8equation_of_line_from_two_pointsmaxCoordinate=20minCoordinate=-20
115Area of Circle given center and a point on circleArea of circle with center (3,1) and passing through (2.35, 0.24) is3.14area_of_circle_given_center_and_pointmaxCoordinate = 10maxRadius=10
117Volume of HemisphereVolume of hemisphere with radius 22 m =22301.119 m^3volume_hemispheremaxRadius=100

misc

IdSkillExample problemExample SolutionFunction NameKwargs
9LCM (Least Common Multiple)LCM of 3 and 5 =15lcmmaxVal=20
10GCD (Greatest Common Denominator)GCD of 3 and 19 =1gcdmaxVal=20
27Prime FactorisationFind prime factors of 185[5, 37]prime_factorsminVal=1maxVal=200
40Common FactorsCommon Factors of 19 and 11 =[1]common_factorsmaxVal=100
51HCF (Highest Common Factor)HCF of 16 and 13 =1hcfmaxVal=20
55Comparing surdsFill in the blanks 41^(1/3) _ 11^(1/4)>surds_comparisonmaxValue=100maxRoot=10
63Profit or Loss PercentLoss percent when CP = 769 and SP = 460 is:40.18205461638492profit_loss_percentmaxCP=1000maxSP=1000
66Geometric ProgressionFor the given GP [12, 72, 432, 2592, 15552, 93312] ,Find the value of a,common ratio,10th term value, sum upto 7th termThe value of a is 12, common ratio is 6 , 10th term is 120932352 , sum upto 7th term is 671844.0geometric_progressionnumber_values=6min_value=2max_value=12n_term=7sum_term=5
67Geometric Mean of N NumbersGeometric mean of 3 numbers 23 , 42 and 80 =(234280)^(1/3) = 42.59471379666575geometric_meanmaxValue=100maxNum=4
68Harmonic Mean of N NumbersHarmonic mean of 2 numbers 19 and 53 =2/((1/19) + (1/53)) = 27.972222222222225harmonic_meanmaxValue=100maxNum=4
69Euclidian norm or L2 norm of a vectorEuclidian norm or L2 norm of the vector[628.9497984743637, 413.7025276967905, 55.08325175633222, 543.4734094406972, 407.4510705587269, 568.7990971658147, 407.9155106455502, 474.20039089590216, 720.3486866530783, 514.2113795291383, 273.3258978495645, 488.8393919190255, 897.4344293916904, 541.0117215640587] is:1985.1961648306578euclidian_normmaxEltAmt=20
81Celsius To FahrenheitConvert 89 degrees Celsius to degrees Fahrenheit =192.20000000000002celsius_to_fahrenheitmaxTemp=100
82AP Term CalculationFind the term number 81 of the AP series: 24, 104, 184 ...6424arithmetic_progression_termmaxd=100maxa=100maxn=100
83AP Sum CalculationFind the sum of first 73 terms of the AP series: -98, -140, -182 ...-117530.0arithmetic_progression_summaxd=100maxa=100maxn=100
85Converts decimal to Roman NumeralsThe number 0 in Roman Numerals is:MMMDXXXIXdecimal_to_roman_numeralsmaxDecimal=4000
92Complex To Polar Form5.1(-1.0theta + i5.0theta)1.77complex_to_polarminRealImaginaryNum=-20, maxRealImaginaryNum=20
93Union,Intersection,Difference of Two SetsGiven the two sets a={1, 4, 5, 6, 9} ,b={2, 3, 5, 6, 7, 8}.Find the Union,intersection,a-b,b-a and symmetric differenceUnion is {1, 2, 3, 4, 5, 6, 7, 8, 9},Intersection is {5, 6}, a-b is {1, 4, 9},b-a is {8, 2, 3, 7}, Symmetric difference is {1, 2, 3, 4, 7, 8, 9}set_operationminval=3maxval=7n_a=4n_b=5
94Base ConversionConvert 40122 from base 5 to base 15.B42base_conversionmaxNum=60000maxBase=16
98Quotient of Powers with Same BaseThe Quotient of 43^10 and 43^1 = 43^(10-1) = 43^9502592611936843quotient_of_power_same_basemaxBase=50maxPower=10
99Quotient of Powers with Same PowerThe Quotient of 1^7 and 1^7 = (1/1)^7 = 1.0^71.0quotient_of_power_same_powermaxBase=50maxPower=10
101Leap Year or NotYear 1986is not a leap yearis_leap_yearminNumber=1900maxNumber=2099
102Minute to Hour conversionConvert 446 minutes to Hours & Minutes7 hours and 26 minutesminutes_to_hoursmaxMinutes=999
106signum functionsignum of 941 is =1signum_functionmin=-999max=999
109Binomial distributionA manufacturer of metal pistons finds that, on average, 37.08% 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?49.63binomial_distribution``
116Factors of a numberFactors of 661 =[1, 661]FactorsmaxVal=1000
121Product of scientific notaionsProduct of scientific notations 7.65x10^-75 and 5.51x10^-50 =4.22x10^-124product_of_scientific_notationsminExpVal=-100maxExpVal=100

statistics

IdSkillExample problemExample SolutionFunction NameKwargs
30Combinations of ObjectsNumber of combinations from 15 objects picked 3 at a time455combinationsmaxlength=20
42PermutationsNumber of Permutations from 16 objects picked 9 at a time =4151347200permutationmaxlength=20
52Probability of a certain sum appearing on faces of diceIf 2 dice are rolled at the same time, the probability of getting a sum of 12 =1/36dice_sum_probabilitymaxDice=3
54Confidence interval For sample SThe confidence interval for sample [234, 254, 283, 218, 205, 251, 282, 228, 280, 202, 268, 220, 273, 277, 267, 249, 285, 208, 225, 266, 274, 235, 223, 226, 245, 200, 213, 221, 298, 236, 288, 231, 222, 299, 243, 242, 255] with 90% confidence is(254.32591454896394, 238.97138274833335)confidence_interval``
59Mean,Standard Deviation,VarianceFind the mean,standard deviation and variance for the data[23, 20, 35, 38, 24, 41, 6, 7, 26, 37, 49, 12, 15, 31, 12]The Mean is 25.066666666666666 , Standard Deviation is 162.32888888888888, Variance is 12.740835486297156data_summarynumber_values=15minval=5maxval=50
76Mean and MedianGiven the series of numbers [2, 8, 9, 14, 16, 17, 35, 47, 55, 74]. find the arithmatic mean and mdian of the seriesArithmetic mean of the series is 27.7 and Arithmetic median of this series is 16.5mean_medianmaxlen=10
107Conditional ProbabilitySomeone tested positive for a nasty disease which only 0.90% of population have. Test sensitivity (true positive) is equal to SN= 98.84% whereas test specificity (true negative) SP= 90.89%. What is the probability that this guy really has that disease?8.97%conditional_probability``

About

A math problem generator, created for the purpose of giving self-studying students and teaching organizations the means to easily get access to high-quality, generated math problems to suit their needs.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages