Merge pull request #33 from ganesh003/patch-7

Updated Basic Algebra Function
This commit is contained in:
Luke Weiler
2020-10-14 20:37:38 -04:00
committed by GitHub

View File

@@ -121,6 +121,26 @@ def lcmFunc(maxVal=20):
solution = str(d) solution = str(d)
return problem, solution 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
return x
i = calculate_gcd((c - b), a)
x = f"{(c - b)//i}/{a//i}"
if (c - b == 0):
x = "0"
elif a == 1 or a == i :
x = f"{c - b}"
problem = f"{a}x + {b} = {c}"
solution = x
return problem, solution
# || Class Instances # || Class Instances
#Format is: #Format is:
@@ -136,3 +156,4 @@ powerRuleDifferentiation = Generator("Power_Rule_Differentiation", 9, "nx^m=", "
square = Generator("Square", 10,"a^2", "b", squareFunc) square = Generator("Square", 10,"a^2", "b", squareFunc)
lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc) lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc)
gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc) gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc)
basicAlgebra = Generator("Basic_Algebra", 13, "ax + b = c", "d", basicAlgebraFunc)