diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index b027f41..1d80853 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -63,6 +63,14 @@ 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)) + c = a%b + problem = str(a) + "%" + str(b) + "=" + solution = str(c) + return problem, solution + # || Class Instances #Format is: @@ -72,4 +80,5 @@ subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) 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) +modulo division = Generator("Modulo Division", 6, "a%b=", "c", moduloFunc)