|
|
|
@@ -4,6 +4,7 @@ import fractions
|
|
|
|
|
|
|
|
|
|
genList = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# || Generator class
|
|
|
|
|
class Generator:
|
|
|
|
|
def __init__(self, title, id, generalProb, generalSol, func):
|
|
|
|
@@ -20,16 +21,19 @@ class Generator:
|
|
|
|
|
def __call__(self, **kwargs):
|
|
|
|
|
return self.func(**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# || Non-generator Functions
|
|
|
|
|
def genById(id):
|
|
|
|
|
generator = genList[id][2]
|
|
|
|
|
return(generator())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getGenList():
|
|
|
|
|
return(genList)
|
|
|
|
|
|
|
|
|
|
# || Generator Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def additionFunc(maxSum=99, maxAddend=50):
|
|
|
|
|
a = random.randint(0, maxAddend)
|
|
|
|
|
b = random.randint(0, min((maxSum - a), maxAddend)) # The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well
|
|
|
|
@@ -38,6 +42,7 @@ def additionFunc(maxSum = 99, maxAddend = 50):
|
|
|
|
|
solution = str(c)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def subtractionFunc(maxMinuend=99, maxDiff=99):
|
|
|
|
|
a = random.randint(0, maxMinuend)
|
|
|
|
|
b = random.randint(max(0, (a - maxDiff)), a)
|
|
|
|
@@ -46,6 +51,7 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99):
|
|
|
|
|
solution = str(c)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def multiplicationFunc(maxRes=99, maxMulti=99):
|
|
|
|
|
a = random.randint(0, maxMulti)
|
|
|
|
|
b = random.randint(0, min(int(maxMulti / a), maxRes))
|
|
|
|
@@ -54,6 +60,7 @@ def multiplicationFunc(maxRes = 99, maxMulti = 99):
|
|
|
|
|
solution = str(c)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def divisionFunc(maxRes=99, maxDivid=99):
|
|
|
|
|
a = random.randint(0, maxDivid)
|
|
|
|
|
b = random.randint(0, min(maxRes, maxDivid))
|
|
|
|
@@ -62,6 +69,7 @@ def divisionFunc(maxRes = 99, maxDivid = 99):
|
|
|
|
|
solution = str(c)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def binaryComplement1sFunc(maxDigits=10):
|
|
|
|
|
question = ''
|
|
|
|
|
answer = ''
|
|
|
|
@@ -74,6 +82,7 @@ def binaryComplement1sFunc(maxDigits = 10):
|
|
|
|
|
solution = answer
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def moduloFunc(maxRes=99, maxModulo=99):
|
|
|
|
|
a = random.randint(0, maxModulo)
|
|
|
|
|
b = random.randint(0, min(maxRes, maxModulo))
|
|
|
|
@@ -82,6 +91,7 @@ def moduloFunc(maxRes = 99, maxModulo= 99):
|
|
|
|
|
solution = str(c)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def squareRootFunc(minNo=1, maxNo=12):
|
|
|
|
|
b = random.randint(minNo, maxNo)
|
|
|
|
|
a = b * b
|
|
|
|
@@ -89,6 +99,7 @@ def squareRootFunc(minNo = 1, maxNo = 12):
|
|
|
|
|
solution = str(b)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
|
|
|
|
numTerms = random.randint(1, maxTerms)
|
|
|
|
|
problem = ""
|
|
|
|
@@ -103,6 +114,7 @@ def powerRuleDifferentiationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5):
|
|
|
|
|
solution += str(coefficient * exponent) + "x^" + str(exponent - 1)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def squareFunc(maxSquareNum=20):
|
|
|
|
|
a = random.randint(1, maxSquareNum)
|
|
|
|
|
b = a * a
|
|
|
|
@@ -110,6 +122,7 @@ def squareFunc(maxSquareNum = 20):
|
|
|
|
|
solution = str(b)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gcdFunc(maxVal=20):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
b = random.randint(1, maxVal)
|
|
|
|
@@ -120,6 +133,7 @@ def gcdFunc(maxVal=20):
|
|
|
|
|
solution = str(x)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def lcmFunc(maxVal=20):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
b = random.randint(1, maxVal)
|
|
|
|
@@ -132,11 +146,13 @@ def lcmFunc(maxVal=20):
|
|
|
|
|
solution = str(d)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def basicAlgebraFunc(maxVariable=10):
|
|
|
|
|
a = random.randint(1, maxVariable)
|
|
|
|
|
b = random.randint(1, maxVariable)
|
|
|
|
|
c = random.randint(b, maxVariable)
|
|
|
|
|
# calculate gcd
|
|
|
|
|
|
|
|
|
|
def calculate_gcd(x, y):
|
|
|
|
|
while(y):
|
|
|
|
|
x, y = y, x % y
|
|
|
|
@@ -151,6 +167,7 @@ def basicAlgebraFunc(maxVariable = 10):
|
|
|
|
|
solution = x
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def logFunc(maxBase=3, maxVal=8):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
b = random.randint(2, maxBase)
|
|
|
|
@@ -159,6 +176,7 @@ def logFunc(maxBase=3, maxVal=8):
|
|
|
|
|
solution = str(a)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def divisionToIntFunc(maxA=25, maxB=25):
|
|
|
|
|
a = random.randint(1, maxA)
|
|
|
|
|
b = random.randint(1, maxB)
|
|
|
|
@@ -168,6 +186,7 @@ def divisionToIntFunc(maxA=25, maxB=25):
|
|
|
|
|
solution = int(divisor / dividend)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def DecimalToBinaryFunc(max_dec=99):
|
|
|
|
|
a = random.randint(1, max_dec)
|
|
|
|
|
b = bin(a).replace("0b", "")
|
|
|
|
@@ -175,15 +194,17 @@ def DecimalToBinaryFunc(max_dec=99):
|
|
|
|
|
solution = str(b)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def BinaryToDecimalFunc(max_dig=10):
|
|
|
|
|
problem = ''
|
|
|
|
|
for i in range(random.randint(1, max_dig)):
|
|
|
|
|
temp = str(random.randint(0, 1))
|
|
|
|
|
problem += temp
|
|
|
|
|
|
|
|
|
|
solution=int(problem, 2);
|
|
|
|
|
solution = int(problem, 2)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def divideFractionsFunc(maxVal=10):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
b = random.randint(1, maxVal)
|
|
|
|
@@ -193,6 +214,7 @@ def divideFractionsFunc(maxVal=10):
|
|
|
|
|
d = random.randint(1, maxVal)
|
|
|
|
|
while (c == d):
|
|
|
|
|
d = random.randint(1, maxVal)
|
|
|
|
|
|
|
|
|
|
def calculate_gcd(x, y):
|
|
|
|
|
while(y):
|
|
|
|
|
x, y = y, x % y
|
|
|
|
@@ -208,6 +230,7 @@ def divideFractionsFunc(maxVal=10):
|
|
|
|
|
solution = x
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100):
|
|
|
|
|
a = random.randint(0, maxMatrixVal)
|
|
|
|
|
b = random.randint(0, maxMatrixVal)
|
|
|
|
@@ -218,6 +241,7 @@ def multiplyIntToMatrix22(maxMatrixVal = 10, maxRes = 100):
|
|
|
|
|
solution = f"[[{a*constant},{b*constant}],[{c*constant},{d*constant}]]"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
|
|
|
|
a = random.randint(1, maxA)
|
|
|
|
|
b = random.randint(1, maxB)
|
|
|
|
@@ -228,6 +252,7 @@ def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
|
|
|
|
solution = area
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def isTriangleValidFunc(maxSideLength=50):
|
|
|
|
|
sideA = random.randint(1, maxSideLength)
|
|
|
|
|
sideB = random.randint(1, maxSideLength)
|
|
|
|
@@ -242,6 +267,7 @@ def isTriangleValidFunc(maxSideLength = 50):
|
|
|
|
|
solution = "No"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def MidPointOfTwoPointFunc(maxValue=20):
|
|
|
|
|
x1 = random.randint(-20, maxValue)
|
|
|
|
|
y1 = random.randint(-20, maxValue)
|
|
|
|
@@ -251,9 +277,11 @@ def MidPointOfTwoPointFunc(maxValue=20):
|
|
|
|
|
solution = f"({(x1+x2)/2},{(y1+y2)/2})"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def factoringFunc(range_x1=10, range_x2=10):
|
|
|
|
|
x1 = random.randint(-range_x1, range_x1)
|
|
|
|
|
x2 = random.randint(-range_x2, range_x2)
|
|
|
|
|
|
|
|
|
|
def intParser(z):
|
|
|
|
|
if (z == 0):
|
|
|
|
|
return ""
|
|
|
|
@@ -278,6 +306,7 @@ def factoringFunc(range_x1 = 10, range_x2 = 10):
|
|
|
|
|
solution = f"(x{x1})(x{x2})"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def thirdAngleOfTriangleFunc(maxAngle=89):
|
|
|
|
|
angle1 = random.randint(1, maxAngle)
|
|
|
|
|
angle2 = random.randint(1, maxAngle)
|
|
|
|
@@ -286,6 +315,7 @@ def thirdAngleOfTriangleFunc(maxAngle=89):
|
|
|
|
|
solution = angle3
|
|
|
|
|
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)
|
|
|
|
@@ -331,6 +361,7 @@ def systemOfEquationsFunc(range_x = 10, range_y = 10, coeff_mult_range=10):
|
|
|
|
|
|
|
|
|
|
# Add random (non-zero) multiple of equations to each other
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
|
|
|
|
|
point1X = random.randint(minValXY, maxValXY + 1)
|
|
|
|
|
point1Y = random.randint(minValXY, maxValXY + 1)
|
|
|
|
@@ -341,6 +372,7 @@ def distanceTwoPointsFunc(maxValXY = 20, minValXY=-20):
|
|
|
|
|
problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pythagoreanTheoremFunc(maxLength=20):
|
|
|
|
|
a = random.randint(1, maxLength)
|
|
|
|
|
b = random.randint(1, maxLength)
|
|
|
|
@@ -349,6 +381,7 @@ def pythagoreanTheoremFunc(maxLength = 20):
|
|
|
|
|
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def linearEquationsFunc(n=2, varRange=20, coeffRange=20):
|
|
|
|
|
if n > 10:
|
|
|
|
|
print("[!] n cannot be greater than 10")
|
|
|
|
@@ -372,6 +405,7 @@ def linearEquationsFunc(n = 2, varRange = 20, coeffRange = 20):
|
|
|
|
|
problem = "\n".join(problem)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def primeFactorsFunc(minVal=1, maxVal=200):
|
|
|
|
|
a = random.randint(minVal, maxVal)
|
|
|
|
|
n = a
|
|
|
|
@@ -389,6 +423,7 @@ def primeFactorsFunc(minVal=1, maxVal=200):
|
|
|
|
|
solution = f"{factors}"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def multiplyFractionsFunc(maxVal=10):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
b = random.randint(1, maxVal)
|
|
|
|
@@ -398,6 +433,7 @@ def multiplyFractionsFunc(maxVal=10):
|
|
|
|
|
b = random.randint(1, maxVal)
|
|
|
|
|
while (c == d):
|
|
|
|
|
d = random.randint(1, maxVal)
|
|
|
|
|
|
|
|
|
|
def calculate_gcd(x, y):
|
|
|
|
|
while(y):
|
|
|
|
|
x, y = y, x % y
|
|
|
|
@@ -412,6 +448,7 @@ def multiplyFractionsFunc(maxVal=10):
|
|
|
|
|
solution = x
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def regularPolygonAngleFunc(minVal=3, maxVal=20):
|
|
|
|
|
sideNum = random.randint(minVal, maxVal)
|
|
|
|
|
problem = f"Find the angle of a regular polygon with {sideNum} sides"
|
|
|
|
@@ -419,6 +456,7 @@ def regularPolygonAngleFunc(minVal = 3,maxVal = 20):
|
|
|
|
|
solution = 180 - exteriorAngle
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def combinationsFunc(maxlength=20):
|
|
|
|
|
|
|
|
|
|
def factorial(a):
|
|
|
|
@@ -430,13 +468,12 @@ def combinationsFunc(maxlength=20):
|
|
|
|
|
a = random.randint(10, maxlength)
|
|
|
|
|
b = random.randint(0, 9)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solution = int(factorial(a) / (factorial(b) * factorial(a - b)))
|
|
|
|
|
problem = "Number of combinations from {} objects picked {} at a time ".format(a, b)
|
|
|
|
|
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def factorialFunc(maxInput=6):
|
|
|
|
|
a = random.randint(0, maxInput)
|
|
|
|
|
n = a
|
|
|
|
@@ -452,6 +489,7 @@ def factorialFunc(maxInput = 6):
|
|
|
|
|
solution = str(b)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def surfaceAreaCube(maxSide=20, unit='m'):
|
|
|
|
|
a = random.randint(1, maxSide)
|
|
|
|
|
problem = f"Surface area of cube with side = {a}{unit} is"
|
|
|
|
@@ -459,6 +497,7 @@ def surfaceAreaCube(maxSide = 20, unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^2"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def volumeCube(maxSide=20, unit='m'):
|
|
|
|
|
a = random.randint(1, maxSide)
|
|
|
|
|
problem = f"Volume of cube with side = {a}{unit} is"
|
|
|
|
@@ -466,6 +505,7 @@ def volumeCube(maxSide = 20, unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^3"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def surfaceAreaCuboid(maxSide=20, unit='m'):
|
|
|
|
|
a = random.randint(1, maxSide)
|
|
|
|
|
b = random.randint(1, maxSide)
|
|
|
|
@@ -476,6 +516,7 @@ def surfaceAreaCuboid(maxSide = 20, unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^2"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def volumeCuboid(maxSide=20, unit='m'):
|
|
|
|
|
a = random.randint(1, maxSide)
|
|
|
|
|
b = random.randint(1, maxSide)
|
|
|
|
@@ -485,6 +526,7 @@ def volumeCuboid(maxSide = 20, unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^3"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
|
|
|
|
a = random.randint(1, maxHeight)
|
|
|
|
|
b = random.randint(1, maxRadius)
|
|
|
|
@@ -493,6 +535,7 @@ def surfaceAreaCylinder(maxRadius = 20, maxHeight = 50,unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^2"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def volumeCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
|
|
|
|
a = random.randint(1, maxHeight)
|
|
|
|
|
b = random.randint(1, maxRadius)
|
|
|
|
@@ -501,6 +544,7 @@ def volumeCylinder(maxRadius = 20, maxHeight = 50, unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^3"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):
|
|
|
|
|
a = random.randint(1, maxHeight)
|
|
|
|
|
b = random.randint(1, maxRadius)
|
|
|
|
@@ -510,6 +554,7 @@ def surfaceAreaCone(maxRadius = 20, maxHeight = 50,unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^2"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def volumeCone(maxRadius=20, maxHeight=50, unit='m'):
|
|
|
|
|
a = random.randint(1, maxHeight)
|
|
|
|
|
b = random.randint(1, maxRadius)
|
|
|
|
@@ -518,6 +563,7 @@ def volumeCone(maxRadius = 20, maxHeight = 50, unit = 'm'):
|
|
|
|
|
solution = f"{ans} {unit}^3"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def commonFactorsFunc(maxVal=100):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
b = random.randint(1, maxVal)
|
|
|
|
@@ -537,6 +583,7 @@ def commonFactorsFunc(maxVal=100):
|
|
|
|
|
solution = arr
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def intersectionOfTwoLinesFunc(
|
|
|
|
|
minM=-10, maxM=10, minB=-10, maxB=10, minDenominator=1, maxDenominator=6
|
|
|
|
|
):
|
|
|
|
@@ -590,6 +637,7 @@ def intersectionOfTwoLinesFunc(
|
|
|
|
|
solution = f"({fractionToString(intersection_x)}, {fractionToString(intersection_y)})"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def permutationFunc(maxlength=20):
|
|
|
|
|
a = random.randint(10, maxlength)
|
|
|
|
|
b = random.randint(0, 9)
|
|
|
|
@@ -597,6 +645,7 @@ def permutationFunc(maxlength=20):
|
|
|
|
|
problem = "Number of Permutations from {} objects picked {} at a time = ".format(a, b)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def vectorCrossFunc(minVal=-20, maxVal=20):
|
|
|
|
|
a = [random.randint(minVal, maxVal) for i in range(3)]
|
|
|
|
|
b = [random.randint(minVal, maxVal) for i in range(3)]
|
|
|
|
@@ -605,6 +654,7 @@ def vectorCrossFunc(minVal=-20, maxVal=20):
|
|
|
|
|
a[0] * b[1] - a[1] * b[0]]
|
|
|
|
|
return str(a) + " X " + str(b) + " = ", str(c)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compareFractionsFunc(maxVal=10):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
b = random.randint(1, maxVal)
|
|
|
|
@@ -629,6 +679,7 @@ def compareFractionsFunc(maxVal=10):
|
|
|
|
|
problem = f"Which symbol represents the comparison between {a}/{b} and {c}/{d}?"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def simpleInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
|
|
|
|
|
a = random.randint(1000, maxPrinciple)
|
|
|
|
|
b = random.randint(1, maxRate)
|
|
|
|
@@ -638,6 +689,7 @@ def simpleInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10):
|
|
|
|
|
solution = round(d, 2)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def matrixMultiplicationFunc(maxVal=100):
|
|
|
|
|
m = random.randint(2, 10)
|
|
|
|
|
n = random.randint(2, 10)
|
|
|
|
@@ -670,6 +722,7 @@ def matrixMultiplicationFunc(maxVal=100):
|
|
|
|
|
solution = matrixMultiplicationFuncHelper(res)
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def matrixMultiplicationFuncHelper(inp):
|
|
|
|
|
m = len(inp)
|
|
|
|
|
n = len(inp[0])
|
|
|
|
@@ -681,6 +734,7 @@ def matrixMultiplicationFuncHelper(inp):
|
|
|
|
|
string += "\n"
|
|
|
|
|
return string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cubeRootFunc(minNo=1, maxNo=1000):
|
|
|
|
|
b = random.randint(minNo, maxNo)
|
|
|
|
|
a = b**(1 / 3)
|
|
|
|
@@ -688,6 +742,7 @@ def cubeRootFunc(minNo = 1, maxNo = 1000):
|
|
|
|
|
solution = str(round(a, 2))
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def powerRuleIntegrationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
|
|
|
|
numTerms = random.randint(1, maxTerms)
|
|
|
|
|
problem = ""
|
|
|
|
@@ -699,7 +754,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 + 1) +")x^" + str(exponent +1)
|
|
|
|
|
solution += "(" + str(coefficient) + "/" + str(exponent) + ")x^" + str(exponent + 1)
|
|
|
|
|
solution = solution + " + c"
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
@@ -714,6 +769,7 @@ def fourthAngleOfQuadriFunc(maxAngle = 180):
|
|
|
|
|
solution = angle4
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def quadraticEquation(maxVal=100):
|
|
|
|
|
a = random.randint(1, maxVal)
|
|
|
|
|
c = random.randint(1, maxVal)
|
|
|
|
@@ -826,8 +882,14 @@ def basicTrigonometryFunc(angles=[0,30,45,60,90],functions=["sin","cos","tan"]):
|
|
|
|
|
|
|
|
|
|
return problem,solution
|
|
|
|
|
|
|
|
|
|
def sumOfAnglesOfPolygonFunc(maxSides = 12):
|
|
|
|
|
side = random.randint(3, maxSides)
|
|
|
|
|
sum = (side - 2) * 180
|
|
|
|
|
problem = f"Sum of angles of polygon with {side} sides = "
|
|
|
|
|
solution = sum
|
|
|
|
|
return problem, solution
|
|
|
|
|
|
|
|
|
|
def data_desc(number_values=15,minval=5,maxval=50):
|
|
|
|
|
def dataSummaryFunc(number_values=15,minval=5,maxval=50):
|
|
|
|
|
random_list=[]
|
|
|
|
|
for i in range(number_values):
|
|
|
|
|
n=random.randint(minval,maxval)
|
|
|
|
@@ -845,14 +907,12 @@ def data_desc(number_values=15,minval=5,maxval=50):
|
|
|
|
|
solution="The Mean is {} , Standard Deviation is {}, Variance is {}".format(mean,var/number_values,(var/number_values)**0.5)
|
|
|
|
|
return problem,solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# || Class Instances
|
|
|
|
|
|
|
|
|
|
# Format is:
|
|
|
|
|
# <title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addition = Generator("Addition", 0, "a+b=", "c", additionFunc)
|
|
|
|
|
subtraction = Generator("Subtraction", 1, "a-b=", "c", subtractionFunc)
|
|
|
|
|
multiplication = Generator("Multiplication", 2, "a*b=", "c", multiplicationFunc)
|
|
|
|
@@ -902,7 +962,7 @@ 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+1)x^(m+1)", powerRuleIntegrationFunc)
|
|
|
|
|
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)
|
|
|
|
|
quadraticEquationSolve = Generator("Quadratic Equation", 50, "Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2", quadraticEquation)
|
|
|
|
|
hcf = Generator("HCF (Highest Common Factor)", 51, "HCF of a and b = ", "c", hcfFunc)
|
|
|
|
@@ -912,4 +972,5 @@ confidenceInterval = Generator("Confidence interval For sample S", 54, "With X%
|
|
|
|
|
surdsComparison = Generator("Comparing surds", 55, "Fill in the blanks a^(1/b) _ c^(1/d)", "</>/=", surdsComparisonFunc)
|
|
|
|
|
fibonacciSeries = Generator("Fibonacci Series",56,"fibonacci series of first a numbers","prints the fibonacci series starting from 0 to a",fibonacciSeriesFunc)
|
|
|
|
|
basicTrigonometry=Generator("Trigonometric Values",57,"What is sin(X)?","ans",basicTrigonometryFunc)
|
|
|
|
|
data_summary=Generator("Mean,Standard Deviation,Variance",58,"a,b,c","Mean:a+b+c/3,Std,Var",data_desc)
|
|
|
|
|
sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58, "Sum of angles of polygon with n sides = ", "sum", sumOfAnglesOfPolygonFunc)
|
|
|
|
|
dataSummary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c", "Mean:a+b+c/3,Std,Var", dataSummaryFunc)
|
|
|
|
|