From 50eff003a30013b2d2494ec95d7e41581da1a901 Mon Sep 17 00:00:00 2001 From: Gokul <43350089+gokulp01@users.noreply.github.com> Date: Thu, 15 Oct 2020 17:26:23 +0530 Subject: [PATCH 1/2] Added Decimal to Binary generator --- mathgenerator/mathgen.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index ed5a3ab..cefaa62 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -156,6 +156,14 @@ def divisionToIntFunc(maxA=25, maxB=25): problem = f"{divisor}/{dividend} = " solution=int(divisor/dividend) return problem,solution + +def decimalToBinary(max_dec=99): + a = random.randint(1, max_dec) + b = bin(a).replace("0b", "") + problem = "Binary of "+str(a)+"=" + solution = str(b) + return problem, solution + # || Class Instances #Format is: @@ -173,4 +181,5 @@ 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) -intdivision = Generator("Easy Divisio",14,"a/b=","c",divisionToIntFunc) \ No newline at end of file +intdivision = Generator("Easy Divisio",14,"a/b=","c",divisionToIntFunc) +decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","c",decimalToBinary) From 2ede20d06d48e1a74998f63f131db2af4792a87b Mon Sep 17 00:00:00 2001 From: Gokul <43350089+gokulp01@users.noreply.github.com> Date: Thu, 15 Oct 2020 17:33:35 +0530 Subject: [PATCH 2/2] Updated Decimal to Binary generator --- mathgenerator/mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index cefaa62..6a0731c 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -182,4 +182,4 @@ 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) intdivision = Generator("Easy Divisio",14,"a/b=","c",divisionToIntFunc) -decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","c",decimalToBinary) +decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","b",decimalToBinary)