From 9fd4a23815bafeba69308dfbd3dbbdf3711de06b Mon Sep 17 00:00:00 2001 From: adit098 Date: Mon, 19 Oct 2020 20:20:38 +0530 Subject: [PATCH] fix #242 --- mathgenerator/funcs/DecimalToHexFunc.py | 11 +++++++++++ mathgenerator/mathgen.py | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 mathgenerator/funcs/DecimalToHexFunc.py diff --git a/mathgenerator/funcs/DecimalToHexFunc.py b/mathgenerator/funcs/DecimalToHexFunc.py new file mode 100644 index 0000000..33945d3 --- /dev/null +++ b/mathgenerator/funcs/DecimalToHexFunc.py @@ -0,0 +1,11 @@ +from .__init__ import * + + +def DecimalToHexFunc(max_dec=99): + a = random.randint(1, max_dec) + b = hex(a).replace("0x", "") + + problem = "Hexadecimal of " + str(a) + "=" + solution = str(b) + + return problem, solution diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0e813a6..e935df8 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -156,3 +156,5 @@ complexNumMultiply = Generator("Multiplication of 2 complex numbers", 64, "(x + geometricprogression=Generator("Geometric Progression", 65, "Initial value,Common Ratio,nth Term,Sum till nth term =", "a,r,ar^n-1,sum(ar^n-1", geomProgrFunc) geometricMean=Generator("Geometric Mean of N Numbers",66,"Geometric mean of n numbers A1 , A2 , ... , An = ","(A1*A2*...An)^(1/n) = ans",geometricMeanFunc) harmonicMean=Generator("Harmonic Mean of N Numbers",67,"Harmonic mean of n numbers A1 , A2 , ... , An = "," n/((1/A1) + (1/A2) + ... + (1/An)) = ans",harmonicMeanFunc) +decimalToHexadecimal = Generator("Decimal to Hexadecimal", 68, + "Hexadecimal of a=", "b", DecimalToHexFunc) \ No newline at end of file