From 7060e19217bcd850368626352e3277e7bb512f07 Mon Sep 17 00:00:00 2001 From: Satyajeet-code <56536469+Satyajeet-code@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:36:43 +0530 Subject: [PATCH] Update mathgen.py --- mathgenerator/mathgen.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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)