| -43 | 66 | 83 | 90 | -22 | -94]] | [[ 3120, -15765, -13401, -2683, -17993, -3354]
+ [ 10584, 13902, 11916, -7446, 4430, 554]
+ [ -1800, 6587, 14343, 6224, 4525, 4853]
+ [-12452, -10675, -8693, 427, 2955, 17691]] | matrixMultiplication |
+| 47 | Cube Root | cuberoot of 221 upto 2 decimal places is: | 6.05 | CubeRoot |
+| 48 | Power Rule Integration | 4x^5 + 2x^5 + 9x^8 + 9x^5 | (4/5)x^6 + (2/5)x^6 + (9/8)x^9 + (9/5)x^6 + c | powerRuleIntegration |
+| 49 | Fourth Angle of Quadrilateral | Fourth angle of quadrilateral with angles 27 , 155, 116 = | 62 | fourthAngleOfQuadrilateral |
+| 50 | Quadratic Equation | Zeros of the Quadratic Equation 53x^2+200x+78=0 | [-0.44, -3.33] | quadraticEquationSolve |
+| 51 | HCF (Highest Common Factor) | HCF of 7 and 4 = | 1 | hcf |
| 52 | Probability of a certain sum appearing on faces of dice | If 2 dice are rolled at the same time, the probability of getting a sum of 11 = | 2/36 | diceSumProbability |
-| 53 | Exponentiation | 9^9 = | 387420489 | exponentiation |
-| 54 | Confidence interval For sample S | The confidence interval for sample [291, 254, 274, 207, 253, 289, 268, 280, 225, 240, 278, 270, 247, 252, 211, 212, 295, 241, 290, 206, 222, 263, 264, 228, 229, 256, 209, 292] with 99% confidence is | (265.560249263099, 237.72546502261523) | confidenceInterval |
-| 55 | Comparing surds | Fill in the blanks 16^(1/7) _ 67^(1/6) | < | surdsComparison |
-| 56 | Fibonacci Series | The Fibonacci Series of the first 11 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] | fibonacciSeries |
-| 57 | Trigonometric Values | What is cos(60)? | 1/2 | basicTrigonometry |
-| 58 | Sum of Angles of Polygon | Sum of angles of polygon with 5 sides = | 540 | sumOfAnglesOfPolygon |
-| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[38, 29, 43, 25, 7, 10, 13, 14, 43, 44, 30, 42, 48, 48, 42] | The Mean is 31.733333333333334 , Standard Deviation is 199.26222222222222, Variance is 14.116027140177303 | dataSummary |
-| 59 | Surface Area of Sphere | Surface area of Sphere with radius = 13m is | 2123.7166338267 m^2 | surfaceAreaSphereGen |
-| 60 | Volume of Sphere | Volume of sphere with radius 84 m = | 2482712.7095377133 m^3 | volumeSphere |
\ No newline at end of file
+| 53 | Exponentiation | 9^10 = | 3486784401 | exponentiation |
+| 54 | Confidence interval For sample S | The confidence interval for sample [266, 201, 278, 209, 229, 275, 216, 234, 219, 276, 282, 281, 208, 247, 265, 273, 286, 202, 231, 207, 251, 203, 259, 288, 291, 260, 210, 263, 222] with 99% confidence is | (260.5668079141175, 231.29526105139982) | confidenceInterval |
+| 55 | Comparing surds | Fill in the blanks 15^(1/9) _ 55^(1/1) | < | surdsComparison |
+| 56 | Fibonacci Series | The Fibonacci Series of the first 10 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] | fibonacciSeries |
+| 57 | Trigonometric Values | What is tan(30)? | 1/√3 | basicTrigonometry |
+| 58 | Sum of Angles of Polygon | Sum of angles of polygon with 3 sides = | 180 | sumOfAnglesOfPolygon |
+| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[36, 13, 31, 23, 38, 34, 24, 20, 41, 14, 19, 31, 11, 49, 49] | The Mean is 28.866666666666667 , Standard Deviation is 143.5822222222222, Variance is 11.982579948501167 | dataSummary |
+| 59 | Surface Area of Sphere | Surface area of Sphere with radius = 11m is | 1520.5308443374597 m^2 | surfaceAreaSphereGen |
+| 60 | Volume of Sphere | Volume of sphere with radius 73 m = | 1629510.5990953872 m^3 | volumeSphere |
+| 61 | nth Fibonacci number | What is the 68th Fibonacci number? | 72723460248141 | nthFibonacciNumberGen |
+| 62 | Profit or Loss Percent | Profit percent when CP = 825 and SP = 972 is: | 17.81818181818182 | profitLossPercent |
+| 63 | Binary to Hexidecimal | 100000 | 0x20 | binaryToHex |
+| 64 | Multiplication of 2 complex numbers | (3+14j) * (-3+16j) = | (-233+6j) | complexNumMultiply |
+| 65 | Geometric Progression | For the given GP [4, 16, 64, 256, 1024, 4096] ,Find the value of a,common ratio,8th term value, sum upto 7th term | The value of a is 4, common ratio is 4 , 8th term is 65536 , sum upto 7th term is 21844.0 | geometricprogression |
+| 66 | Geometric Mean of N Numbers | Geometric mean of 3 numbers 81 , 35 and 99 = | (81*35*99)^(1/3) = 65.47307713912309 | geometricMean |
+| 67 | Harmonic Mean of N Numbers | Harmonic mean of 2 numbers 99 and 25 = | 2/((1/99) + (1/25)) = 39.91935483870967 | harmonicMean |
diff --git a/makeReadme.py b/makeReadme.py
index 64f7989..796dc00 100644
--- a/makeReadme.py
+++ b/makeReadme.py
@@ -1,25 +1,51 @@
# To use, paste at bottom of mathgen.py code, change line variable and remove all table rows in README.md except for the top 2 and run mathgen.py
+# NOTE: not anymore. but still leaving this comment in.
+from mathgenerator.mathgen import *
wList = getGenList()
+lines = []
+with open('mathgenerator/mathgen.py', 'r') as f:
+ lines=f.readlines()
+
allRows = []
-f = open('mathgen.py')
-lines = f.readlines()
-line = 720 # This has to be changed depending on which line the first generator appears on
+line = lines.index('# Funcs_start - DO NOT REMOVE!\n')+1 # get the first line of the functions in mathgen.py
for item in wList:
myGen = item[2]
- prob, sol = myGen()
+ # NOTE: renamed 'sol' to 'solu' to make it look nicer
+ prob, solu = myGen()
prob = str(prob).rstrip("\n")
- sol = str(sol).rstrip("\n")
+ solu = str(solu).rstrip("\n")
+ # edge case for matrixMultiplication
+ if item[0] == 46:
+ print(prob)
+
+ prob = prob.replace("[[", "| ")
+ prob = prob.replace("[", " | | ")
+ prob = prob.replace(", ", " | ")
+ prob = prob.replace("]]\n", " | ")
+ prob = prob.replace("]\n", " |
")
+ print(prob)
+
instName = lines[line]
- def_name = instName[:instName.find('=')].strip()
- row = [myGen.id, myGen.title, prob, sol, def_name]
+ func_name = instName[:instName.find('=')].strip() # NOTE: renamed 'def_name' to 'func_name' because it suits it more
+ row = [myGen.id, myGen.title, prob, solu, func_name]
+ # print(item[1], func_name)
line += 1
+ if line > len(lines):
+ break
allRows.append(row)
-g = open('../README.md', "a")
-for row in allRows:
- tableLine = "| " + str(row[0]) + " | " + str(row[1]) + " | " + str(row[2]) + " | " + str(row[3]) + " | " + str(row[4]) + " |\n"
- g.write(tableLine)
-g.close()
+with open('README.md', "r") as g:
+ lines = g.readlines()
+
+ line = lines.index('[//]: # list start\n')
+ lines = lines[:line+1]
+
+ for row in allRows:
+ tableLine = "| " + str(row[0]) + " | " + str(row[1]) + " | " + str(row[2]) + " | " + str(row[3]) + " | " + str(row[4]) + " |\n"
+ lines.append(tableLine)
+
+with open('README.md', "w") as g:
+ g.writelines(lines)
print("New README.md table generated")
diff --git a/mathgenerator/funcs/matrixMultiplicationFunc.py b/mathgenerator/funcs/matrixMultiplicationFunc.py
index de69218..eeaa265 100644
--- a/mathgenerator/funcs/matrixMultiplicationFunc.py
+++ b/mathgenerator/funcs/matrixMultiplicationFunc.py
@@ -40,11 +40,12 @@ def matrixMultiplicationFuncHelper(inp):
m = len(inp)
n = len(inp[0])
- string = ""
+ string = "[["
for i in range(m):
for j in range(n):
string += f"{inp[i][j]: 6d}"
- string += " "
- string += "\n"
+ string += ", "if j < n-1 else ""
+ string += "]\n [" if i < m-1 else ""
+ string += "]]"
return string
\ No newline at end of file
diff --git a/mathgenerator/funcs/moduloFunc.py b/mathgenerator/funcs/moduloFunc.py
index 5f8d2af..71f1421 100644
--- a/mathgenerator/funcs/moduloFunc.py
+++ b/mathgenerator/funcs/moduloFunc.py
@@ -4,7 +4,7 @@ from .__init__ import *
def moduloFunc(maxRes=99, maxModulo=99):
a = random.randint(0, maxModulo)
b = random.randint(0, min(maxRes, maxModulo))
- c = a % b
+ c = a % b if b != 0 else 0
problem = str(a) + "%" + str(b) + "="
solution = str(c)
diff --git a/mathgenerator/funcs/profitLossPercentFunc.py b/mathgenerator/funcs/profitLossPercentFunc.py
index 533c294..05a3653 100644
--- a/mathgenerator/funcs/profitLossPercentFunc.py
+++ b/mathgenerator/funcs/profitLossPercentFunc.py
@@ -12,3 +12,5 @@ def profitLossPercentFunc(maxCP = 1000, maxSP = 1000):
percent = diff/cP * 100
problem = f"{profitOrLoss} percent when CP = {cP} and SP = {sP} is: "
solution = percent
+
+ return problem, solution
\ No newline at end of file
diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py
index 0e813a6..3265a0f 100644
--- a/mathgenerator/mathgen.py
+++ b/mathgenerator/mathgen.py
@@ -33,126 +33,73 @@ def getGenList():
# Format is:
#