From 35d90136e4134e01548c594ee789dbac125e56cd Mon Sep 17 00:00:00 2001 From: shyambhu Date: Sat, 17 Oct 2020 01:23:45 +0530 Subject: [PATCH 1/4] added cube root function. --- mathgenerator/mathgen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 940dd90..0b15947 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -89,6 +89,13 @@ def squareRootFunc(minNo = 1, maxNo = 12): solution = str(b) return problem, solution +def cubeRootFunc(minNo = 1, maxNo = 1000): + b = random.randint(minNo, maxNo) + a = b**(1/3) + problem = "cuberoot of " + str(b) + " upto 2 decimal places is:" + solution = str(round(a,2)) + return problem, solution + def powerRuleDifferentiationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): numTerms = random.randint(1, maxTerms) problem = "" @@ -633,3 +640,4 @@ surfaceAreaConeGen = Generator("Surface Area of cone", 38, "Surface area of cone 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) intersectionOfTwoLines = Generator("Intersection of Two Lines", 41, "Find the point of intersection of the two lines: y = m1*x + b1 and y = m2*x + b2", "(x, y)", intersectionOfTwoLinesFunc) +CubeRoot = Generator("Cube Root",42,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) \ No newline at end of file From f4aa55385863f58252a1a0bfc4f8b42d1eed2361 Mon Sep 17 00:00:00 2001 From: shyambhu Date: Sat, 17 Oct 2020 01:38:43 +0530 Subject: [PATCH 2/4] added power rule integration function. --- mathgenerator/mathgen.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0b15947..5a141af 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -110,6 +110,21 @@ def powerRuleDifferentiationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): solution += str(coefficient * exponent) + "x^" + str(exponent - 1) return problem, solution +def powerRuleIntegrationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): + numTerms = random.randint(1, maxTerms) + problem = "" + solution = "" + for i in range(numTerms): + if i > 0: + problem += " + " + solution += " + " + 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 = solution + " + c" + return problem, solution + def squareFunc(maxSquareNum = 20): a = random.randint(1, maxSquareNum) b = a * a From 3b2f707f2e1cfc95581f300c57a012b52025927c Mon Sep 17 00:00:00 2001 From: shyambhu Date: Sat, 17 Oct 2020 01:43:12 +0530 Subject: [PATCH 3/4] corrected integration. --- mathgenerator/mathgen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 5a141af..cf661d8 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -655,4 +655,5 @@ surfaceAreaConeGen = Generator("Surface Area of cone", 38, "Surface area of cone 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) intersectionOfTwoLines = Generator("Intersection of Two Lines", 41, "Find the point of intersection of the two lines: y = m1*x + b1 and y = m2*x + b2", "(x, y)", intersectionOfTwoLinesFunc) -CubeRoot = Generator("Cube Root",42,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) \ No newline at end of file +CubeRoot = Generator("Cube Root",42,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) +powerRuleIntegration = Generator("Power Rule Integration", 43, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) \ No newline at end of file From b6c35922f49d7cce48aac06cd8fd4d5d22add3ee Mon Sep 17 00:00:00 2001 From: shyambhu Date: Sat, 17 Oct 2020 02:13:16 +0530 Subject: [PATCH 4/4] added fourth angle of quadrilateral function. --- mathgenerator/mathgen.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index cf661d8..87567d5 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -308,6 +308,16 @@ def thirdAngleOfTriangleFunc(maxAngle=89): solution = angle3 return problem, solution +def fourthAngleOfQuadriFunc(maxAngle = 180): + angle1 = random.randint(1, maxAngle) + angle2 = random.randint(1, 240-angle1) + angle3 = random.randint(1, 340-(angle1 + angle2)) + sum_ = angle1 + angle2 + angle3 + angle4 = 360 - sum_ + problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} =" + solution = angle4 + return problem, solution + def systemOfEquationsFunc(range_x = 10, range_y = 10, coeff_mult_range=10): # Generate solution point first x = random.randint(-range_x, range_x) @@ -656,4 +666,5 @@ volumeConeGen = Generator("Volume of cone", 39, "Volume of cone with height = a commonFactors = Generator("Common Factors", 40, "Common Factors of {a} and {b} = ","[c, d, ...]",commonFactorsFunc) intersectionOfTwoLines = Generator("Intersection of Two Lines", 41, "Find the point of intersection of the two lines: y = m1*x + b1 and y = m2*x + b2", "(x, y)", intersectionOfTwoLinesFunc) CubeRoot = Generator("Cube Root",42,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) -powerRuleIntegration = Generator("Power Rule Integration", 43, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) \ No newline at end of file +powerRuleIntegration = Generator("Power Rule Integration", 43, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) +fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",44,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) \ No newline at end of file