From 991da6949e3af35bc1b5cd39676b766ba00f3095 Mon Sep 17 00:00:00 2001 From: Thromax Date: Thu, 15 Oct 2020 02:46:41 +0200 Subject: [PATCH] Added logarithm Added logarithm --- mathgenerator/mathgen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 791a047..322f429 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -140,6 +140,13 @@ 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) + c = pow(b,a) + problem = "log"+str(b)+"("+str(c)+")" + solution = str(a) + return problem, solution # || Class Instances @@ -157,3 +164,4 @@ square = Generator("Square", 10,"a^2", "b", squareFunc) lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc) gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc) basicAlgebra = Generator("Basic_Algebra", 13, "ax + b = c", "d", basicAlgebraFunc) +log = Generator("Logarithm", 13, "log2(8)", "3", logFunc)