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)