diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 109c9b8..0931109 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -71,6 +71,13 @@ def moduloFunc(maxRes = 99, maxModulo= 99): solution = str(c) return problem, solution +def squareRootFunction(minNo = 1, maxNo = 12): + b = random.randint(minNo, maxNo) + a = b*b + problem = "sqrt(" + str(a) + ")=" + solution = str(b) + return problem, solution + # || Class Instances #Format is: @@ -81,4 +88,4 @@ multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) binaryComplement1s = Generator("binary_complement_1s", 6, "1010=", "0101", binaryComplement1sFunc) moduloDivision = Generator("Modulo_Division", 7, "a%b=", "c", moduloFunc) - +squareRoot = Generator("Square _Root", 8, "sqrt(a)=", "b", squareRootFunction) \ No newline at end of file