From bac53548085b8fac4375ca93fb614f74489eaa5c Mon Sep 17 00:00:00 2001 From: Shiven Tripathi <58358532+ShivenTripathi@users.noreply.github.com> Date: Fri, 16 Oct 2020 23:56:22 +0530 Subject: [PATCH 01/11] add problem to find roots of quadratic equation --- mathgenerator/mathgen.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 917fccc..90cd1ac 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -531,6 +531,15 @@ def commonFactorsFunc(maxVal=100): problem = f"Common Factors of {a} and {b} = " solution = arr return problem, solution + +def quadraticEquation(maxVal=100): + a = random.randint(1,maxVal) + c = random.randint(1,maxVal) + b = random.randint(4*a*c,4*maxVal*maxVal) + + problem = "Zeros of the Quadratic Equation {a}x^2+{b}x+{c}=0".format(a,b,c) + solution = str[(-b+sqrt(b^2-4*a*c))/2*a,(-b-sqrt(b^2-4*a*c))/2*a] + return problem,solution # || Class Instances #Format is: @@ -577,3 +586,4 @@ volumeCylinderGen = Generator("Volume of cylinder", 37, "Volume of cylinder with surfaceAreaConeGen = Generator("Surface Area of cone", 38, "Surface area of cone with height = a units and radius = b units is","c units^2", surfaceAreaCone) volumeConeGen = Generator("Volume of cone", 39, "Volume of cone with height = a units and radius = b units is","c units^3", volumeCone) commonFactors = Generator("Common Factors", 40, "Common Factors of {a} and {b} = ","[c, d, ...]",commonFactorsFunc) +quadraticEquationSolve = Generator("Quadratic Equation", 41, "Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2", quadraticEquation) From 1572bd616c473906914c2e72f7fcff6b9971600f Mon Sep 17 00:00:00 2001 From: c0d3nh4ck <50226641+c0d3nh4ck@users.noreply.github.com> Date: Sat, 17 Oct 2020 08:01:21 +0530 Subject: [PATCH 02/11] added HCF function --- mathgenerator/mathgen.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1041a55..660a961 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -714,6 +714,17 @@ def fourthAngleOfQuadriFunc(maxAngle = 180): solution = angle4 return problem, solution + +def hcfFunc(maxVal=20): + a = random.randint(1, maxVal) + b = random.randint(1, maxVal) + x, y = a, b + while(y): + x, y = y, x % y + problem = f"HCF of {a} and {b} = " + solution = str(x) + return problem, solution + # || Class Instances #Format is: @@ -769,3 +780,4 @@ matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multipl CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) +hcf = Generator("HCF (Highest Common Factor)", 50, "HCF of a and b = ", "c", hcfFunc) From dedbb7027e1f53cad75608991fdd6d50de75589d Mon Sep 17 00:00:00 2001 From: Ritu Raj <68614399+Ritu1611@users.noreply.github.com> Date: Sat, 17 Oct 2020 11:47:30 +0530 Subject: [PATCH 03/11] Probability Function for Sum on dice faces --- mathgenerator/mathgen.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1041a55..866a2f2 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -714,6 +714,27 @@ def fourthAngleOfQuadriFunc(maxAngle = 180): solution = angle4 return problem, solution +def DiceSumProbFunc(maxDice=3): + a = random.randint(1,maxDice) + b = random.randint(a,6*a) + count=0 + for i in [1,2,3,4,5,6]: + if a==1: + if i==b: + count=count+1 + elif a==2: + for j in [1,2,3,4,5,6]: + if i+j==b: + count=count+1 + elif a==3: + for j in [1,2,3,4,5,6]: + for k in [1,2,3,4,5,6]: + if i+j+k==b: + count=count+1 + problem = "If {} dices rolled at the same time, Probability of getting a sum of {} =".format(a,b) + solution="{}/{}".format(count, 6**a) + return problem, solution + # || Class Instances #Format is: @@ -769,3 +790,4 @@ matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multipl CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) +DiceSumProbability=Generator("Probability of a certain sum appearing on faces of dice",50,"If n dices are rolled then probabilty of getting sum of x is", DiceSumProbFunc) From e3834b2c8951be2670dc6a8a3ea64c7eca81725a Mon Sep 17 00:00:00 2001 From: Ritu Raj <68614399+Ritu1611@users.noreply.github.com> Date: Sat, 17 Oct 2020 11:54:50 +0530 Subject: [PATCH 04/11] Update mathgen.py --- mathgenerator/mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 866a2f2..a5164a1 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -790,4 +790,4 @@ matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multipl CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) -DiceSumProbability=Generator("Probability of a certain sum appearing on faces of dice",50,"If n dices are rolled then probabilty of getting sum of x is", DiceSumProbFunc) +DiceSumProbability=Generator("Probability of a certain sum appearing on faces of dice",50,"If n dices are rolled then probabilty of getting sum of x is =","z", DiceSumProbFunc) From 91b42f8ab6287219c767ed38937db1508f853414 Mon Sep 17 00:00:00 2001 From: palmcm Date: Sat, 17 Oct 2020 13:38:19 +0700 Subject: [PATCH 05/11] Add exponentiation function --- mathgenerator/mathgen.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1041a55..0722c35 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -714,6 +714,12 @@ def fourthAngleOfQuadriFunc(maxAngle = 180): solution = angle4 return problem, solution +def exponentiationFunc(maxBase = 20,maxExpo = 10): + base = random.randint(1, maxBase) + expo = random.randint(1, maxExpo) + problem = f"{base}^{expo} =" + solution = str(base ** expo) + return problem, solution # || Class Instances #Format is: @@ -769,3 +775,4 @@ matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multipl CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) +exponentiation = Generator("Exponentiation",50,"a^b = ","c",exponentiationFunc) \ No newline at end of file From efc3df0b275784b1cce4fa3e182b4f974317e427 Mon Sep 17 00:00:00 2001 From: Ritu Raj <68614399+Ritu1611@users.noreply.github.com> Date: Sat, 17 Oct 2020 13:22:26 +0530 Subject: [PATCH 06/11] Confidence Interval Problem Generator --- mathgenerator/mathgen.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1041a55..e7da9a6 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -713,6 +713,27 @@ def fourthAngleOfQuadriFunc(maxAngle = 180): problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} =" solution = angle4 return problem, solution +def confidenceIntervalFunc(): + n=random.randint(20,40) + j=random.randint(1,4) + lst=random.sample(range(200,300),n) + lst_per=[80 ,90, 95, 99] + lst_t = [1.282, 1.645, 1.960, 2.576] + mean=0 + sd=0 + for i in lst: + count= i + mean + mean=count + mean = mean/n + for i in lst: + x=(i-mean)**2+sd + sd=x + sd=sd/n + standard_error = lst_t[j]*math.sqrt(sd/n) + problem= 'The confidence interval for sample {} with {}% confidence is'.format([x for x in lst], lst_per[j]) + solution= '({}, {})'.format(mean+standard_error, mean-standard_error) + return problem, solution + # || Class Instances @@ -769,3 +790,4 @@ matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multipl CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) +ConfidenceInterval = Generator("Confidence interval For sample S", 51, "With X% confidence", "is (A,B)", confidenceIntervalFunc) From 6651379fb82862edd1b970fec65ddbebbd3c7549 Mon Sep 17 00:00:00 2001 From: MaxwellJpg <70202524+MaxwellJpg@users.noreply.github.com> Date: Sat, 17 Oct 2020 10:26:46 +0100 Subject: [PATCH 07/11] Update README.md correct row 26 of table --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index dfc7d41..3f3ab03 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,7 @@ problem, solution = mathgen.genById(0) | 23 | Solve a System of Equations in R^2 | 4x - 8y = 48, 3x - 8y = 40 | x = 8, y = -2 | systemOfEquations | | 24 | Distance between 2 points | Find the distance between (-9, -20) and (18, -19) | sqrt(730) | distance2Point | | 25 | Pythagorean Theorem | The hypotenuse of a right triangle given the other two lengths 18 and 13 = | 22.20 | pythagoreanTheorem | -| 26 | Linear Equations | -11x + -16y = -302 -1x + 20y = 250 | x = 10, y = 12 | linearEquations | +| 26 | Linear Equations | -11x + -16y = -302 , 1x + 20y = 250 | x = 10, y = 12 | linearEquations | | 27 | Prime Factorisation | Find prime factors of 55 | [5, 11] | primeFactors | | 28 | Fraction Multiplication | (4/9)*(8/10) | 16/45 | fractionMultiplication | | 29 | Angle of a Regular Polygon | Find the angle of a regular polygon with 15 sides | 156.0 | angleRegularPolygon | From e2857e8f18aff94aee4fb02265842d6d075374d8 Mon Sep 17 00:00:00 2001 From: MaxwellJpg Date: Sat, 17 Oct 2020 12:26:10 +0100 Subject: [PATCH 08/11] correct int powerRuleIntegrationFunc --- mathgenerator/mathgen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1041a55..3c67452 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -699,7 +699,7 @@ def powerRuleIntegrationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): coefficient = random.randint(1, maxCoef) exponent = random.randint(1, maxExp) problem += str(coefficient) + "x^" + str(exponent) - solution += "("+str(coefficient) +"/"+str(exponent) +")x^" + str(exponent +1) + solution += "("+str(coefficient) +"/"+str(exponent + 1) +")x^" + str(exponent +1) solution = solution + " + c" return problem, solution @@ -767,5 +767,5 @@ compareFractions=Generator("Compare Fractions",44,"Which symbol represents the c simpleInterest = Generator("Simple Interest", 45, "Simple interest for a principle amount of a dollars, b% rate of interest and for a time period of c years is = ", "d dollars", simpleInterestFunc) matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multiply two matrices A and B", "C", matrixMultiplicationFunc) CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) -powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) +powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m+1)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) From 2b5a8135dc47f1209103fbbb75804ffb3a82bd09 Mon Sep 17 00:00:00 2001 From: Shiven Tripathi <58358532+ShivenTripathi@users.noreply.github.com> Date: Sat, 17 Oct 2020 18:22:20 +0530 Subject: [PATCH 09/11] debug, tested --- mathgenerator/mathgen.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 90cd1ac..fda0d0e 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -535,10 +535,13 @@ def commonFactorsFunc(maxVal=100): def quadraticEquation(maxVal=100): a = random.randint(1,maxVal) c = random.randint(1,maxVal) - b = random.randint(4*a*c,4*maxVal*maxVal) + b = random.randint(round(math.sqrt(4*a*c))+1,round(math.sqrt(4*maxVal*maxVal))) - problem = "Zeros of the Quadratic Equation {a}x^2+{b}x+{c}=0".format(a,b,c) - solution = str[(-b+sqrt(b^2-4*a*c))/2*a,(-b-sqrt(b^2-4*a*c))/2*a] + problem = "Zeros of the Quadratic Equation {}x^2+{}x+{}=0".format(a,b,c) + + D = math.sqrt(b*b-4*a*c) + + solution = str([(-b+D)/(2*a),(-b-D)/(2*a)]) return problem,solution # || Class Instances From e2bbbee7c6957ac6276c9b95dad579fcc93745ac Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Sat, 17 Oct 2020 12:54:30 -0400 Subject: [PATCH 10/11] Rounded solution --- mathgenerator/mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 3a44119..72eb108 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -723,7 +723,7 @@ def quadraticEquation(maxVal=100): D = math.sqrt(b*b-4*a*c) - solution = str([(-b+D)/(2*a),(-b-D)/(2*a)]) + solution = str([round((-b+D)/(2*a), 2),round((-b-D)/(2*a), 2)]) return problem,solution # || Class Instances From 8c326f827842044c719b7883aec392c58d144660 Mon Sep 17 00:00:00 2001 From: Ritu Raj <68614399+Ritu1611@users.noreply.github.com> Date: Sat, 17 Oct 2020 22:58:11 +0530 Subject: [PATCH 11/11] Update mathgen.py --- mathgenerator/mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index e7da9a6..2515683 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -715,7 +715,7 @@ def fourthAngleOfQuadriFunc(maxAngle = 180): return problem, solution def confidenceIntervalFunc(): n=random.randint(20,40) - j=random.randint(1,4) + j=random.randint(0,3) lst=random.sample(range(200,300),n) lst_per=[80 ,90, 95, 99] lst_t = [1.282, 1.645, 1.960, 2.576]