From b89c9c3178fbb5e3ebadd00c7298a626031a3f63 Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Mon, 19 Oct 2020 22:12:24 +0530 Subject: [PATCH 1/9] Added Set operatiosn fucntion, corrected compound interest --- mathgenerator/funcs/compoundInterestFunc.py | 2 +- mathgenerator/funcs/set_operation.py | 18 ++++++++++++++++++ mathgenerator/mathgen.py | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 mathgenerator/funcs/set_operation.py diff --git a/mathgenerator/funcs/compoundInterestFunc.py b/mathgenerator/funcs/compoundInterestFunc.py index dec3e54..6f4fba3 100644 --- a/mathgenerator/funcs/compoundInterestFunc.py +++ b/mathgenerator/funcs/compoundInterestFunc.py @@ -1,6 +1,6 @@ from .__init__ import * -def compoundInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10, maxPeriod = ): +def compoundInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10, maxPeriod = 10): p = random.randint(100, maxPrinciple) r = random.randint(1, maxRate) t = random.randint(1, maxTime) diff --git a/mathgenerator/funcs/set_operation.py b/mathgenerator/funcs/set_operation.py new file mode 100644 index 0000000..6842efd --- /dev/null +++ b/mathgenerator/funcs/set_operation.py @@ -0,0 +1,18 @@ +from .__init__ import * + + +def set_operation(minval=3,maxval=7,n_a=4,n_b=5): + number_variables_a=random.randint(minval,maxval) + number_variables_b=random.randint(minval,maxval) + a=[] + b=[] + for i in range(number_variables_a): + a.append(random.randint(1,10)) + for i in range(number_variables_b): + b.append(random.randint(1,10)) + + a=set(a) + b=set(b) + problem= "Given the two sets a=" + str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference" + solution="Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is "+str(a.difference(b)) + ",b-a is " + str(b.difference(a))+ ", Symmetric difference is "+ str(a.symmetric_difference(b)) + return problem,solution diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 9f570cc..57069d8 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -114,3 +114,4 @@ meanMedian=Generator("Mean and Median", 76,"Mean and median of given set of numb intMatrix22determinant = Generator("Determinant to 2x2 Matrix", 77, "Det([[a,b],[c,d]]) =", " a * d - b * c", determinantToMatrix22) compoundInterest = Generator("Compound Interest", 78, "Compound interest for a principle amount of p dollars, r% rate of interest and for a time period of t years with n times compounded annually is = ", "A dollars", compoundInterestFunc) decimalToHexadeci = Generator("Decimal to Hexadecimal", 79,"Binary of a=", "b", deciToHexaFunc) +setoperations = Generator("Union,Intersection,Difference of Two Sets", 80, "Union,intersection,difference", "aUb,a^b,a-b,b-a,", set_operation) \ No newline at end of file From 98b91030d6bab1899624fe3f3dda9c344aaa95dd Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Mon, 19 Oct 2020 22:21:37 +0530 Subject: [PATCH 2/9] lint spacing --- mathgenerator/funcs/set_operation.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/mathgenerator/funcs/set_operation.py b/mathgenerator/funcs/set_operation.py index 6842efd..370c827 100644 --- a/mathgenerator/funcs/set_operation.py +++ b/mathgenerator/funcs/set_operation.py @@ -1,18 +1,16 @@ from .__init__ import * - -def set_operation(minval=3,maxval=7,n_a=4,n_b=5): - number_variables_a=random.randint(minval,maxval) - number_variables_b=random.randint(minval,maxval) - a=[] - b=[] +def set_operation(minval = 3, maxval = 7, n_a = 4, n_b = 5): + number_variables_a = random.randint(minval, maxval) + number_variables_b = random.randint(minval, maxval) + a = [] + b = [] for i in range(number_variables_a): - a.append(random.randint(1,10)) + a.append(random.randint(1, 10)) for i in range(number_variables_b): - b.append(random.randint(1,10)) - + b.append(random.randint(1, 10)) a=set(a) b=set(b) - problem= "Given the two sets a=" + str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference" - solution="Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is "+str(a.difference(b)) + ",b-a is " + str(b.difference(a))+ ", Symmetric difference is "+ str(a.symmetric_difference(b)) - return problem,solution + problem = "Given the two sets a=" + str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference" + solution ="Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is " + str(a.difference(b)) + ",b-a is " + str(b.difference(a)) + ", Symmetric difference is " + str(a.symmetric_difference(b)) + return problem, solution From 1fea870a39add033bbc50878ca4079495374c34c Mon Sep 17 00:00:00 2001 From: NarayanAdithya <57533346+NarayanAdithya@users.noreply.github.com> Date: Mon, 19 Oct 2020 22:23:54 +0530 Subject: [PATCH 3/9] Update readme for set_operationfucn --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f2d81dc..c33d765 100644 --- a/README.md +++ b/README.md @@ -104,3 +104,4 @@ problem, solution = mathgen.genById(0) | 65 | Geometric Progression | For the given GP [4, 16, 64, 256, 1024, 4096] ,Find the value of a,common ratio,8th term value, sum upto 7th term | The value of a is 4, common ratio is 4 , 8th term is 65536 , sum upto 7th term is 21844.0 | geometricprogression | | 66 | Geometric Mean of N Numbers | Geometric mean of 3 numbers 81 , 35 and 99 = | (81*35*99)^(1/3) = 65.47307713912309 | geometricMean | | 67 | Harmonic Mean of N Numbers | Harmonic mean of 2 numbers 99 and 25 = | 2/((1/99) + (1/25)) = 39.91935483870967 | harmonicMean | +| 80 | Set Operations | Given sets A,B | A^B,A-B,B-A,A U B, | set_operation| From 2f359086fa704ad5f578f368819c984d794f8455 Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Tue, 20 Oct 2020 10:26:22 +0530 Subject: [PATCH 4/9] Lint Issues --- mathgenerator/funcs/compoundInterestFunc.py | 1 + mathgenerator/funcs/set_operation.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mathgenerator/funcs/compoundInterestFunc.py b/mathgenerator/funcs/compoundInterestFunc.py index 6f4fba3..bd3664e 100644 --- a/mathgenerator/funcs/compoundInterestFunc.py +++ b/mathgenerator/funcs/compoundInterestFunc.py @@ -1,5 +1,6 @@ from .__init__ import * + def compoundInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10, maxPeriod = 10): p = random.randint(100, maxPrinciple) r = random.randint(1, maxRate) diff --git a/mathgenerator/funcs/set_operation.py b/mathgenerator/funcs/set_operation.py index 370c827..4f0a27a 100644 --- a/mathgenerator/funcs/set_operation.py +++ b/mathgenerator/funcs/set_operation.py @@ -1,6 +1,7 @@ from .__init__ import * -def set_operation(minval = 3, maxval = 7, n_a = 4, n_b = 5): + +def set_operation(minval=3, maxval=7, n_a=4, n_b=5): number_variables_a = random.randint(minval, maxval) number_variables_b = random.randint(minval, maxval) a = [] @@ -12,5 +13,5 @@ def set_operation(minval = 3, maxval = 7, n_a = 4, n_b = 5): a=set(a) b=set(b) problem = "Given the two sets a=" + str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference" - solution ="Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is " + str(a.difference(b)) + ",b-a is " + str(b.difference(a)) + ", Symmetric difference is " + str(a.symmetric_difference(b)) + solution = "Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is " + str(a.difference(b)) + ",b-a is " + str(b.difference(a)) + ", Symmetric difference is " + str(a.symmetric_difference(b)) return problem, solution From 7139a8aece31009f6f45fd43e928859464252951 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 21 Oct 2020 14:13:49 -0400 Subject: [PATCH 5/9] Update compoundInterestFunc.py --- mathgenerator/funcs/compoundInterestFunc.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mathgenerator/funcs/compoundInterestFunc.py b/mathgenerator/funcs/compoundInterestFunc.py index 9c9d290..d357bed 100644 --- a/mathgenerator/funcs/compoundInterestFunc.py +++ b/mathgenerator/funcs/compoundInterestFunc.py @@ -2,15 +2,12 @@ from .__init__ import * from ..__init__ import Generator -<<<<<<< HEAD -def compoundInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10, maxPeriod = 10): -======= + def compoundInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10, maxPeriod=10): ->>>>>>> cb0cfb4b81966d8bccb88d30dfce099e05c8b4f4 p = random.randint(100, maxPrinciple) r = random.randint(1, maxRate) t = random.randint(1, maxTime) From aff60a3d3cccf04bd9c02ac4999d9f190f4afe63 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 21 Oct 2020 14:14:03 -0400 Subject: [PATCH 6/9] Update compoundInterestFunc.py --- mathgenerator/funcs/compoundInterestFunc.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mathgenerator/funcs/compoundInterestFunc.py b/mathgenerator/funcs/compoundInterestFunc.py index d357bed..60a3f40 100644 --- a/mathgenerator/funcs/compoundInterestFunc.py +++ b/mathgenerator/funcs/compoundInterestFunc.py @@ -2,8 +2,6 @@ from .__init__ import * from ..__init__ import Generator - - def compoundInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10, From d745080c0a680f56093ebe327f1b992b9db59477 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 21 Oct 2020 14:14:22 -0400 Subject: [PATCH 7/9] Update README.md --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index dc4cab7..5306ab5 100644 --- a/README.md +++ b/README.md @@ -114,8 +114,3 @@ problem, solution = mathgen.genById(0) | 78 | Compound Interest | Compound Interest for a principle amount of 4156 dollars, 8% rate of interest and for a time period of 7 compounded monthly is = | 4156.0 | surfaceAreaCylinderGen | | 79 | Decimal to Hexadecimal | Binary of 143= | 0x8f | "Surface Area of Cylinder", 34, | | 80 | Percentage of a number | What is 49% of 13? | Required percentage = 6.37% | "Surface area of cylinder with height | -| 81 | Celsius To Fahrenheit | Convert 39 degrees Celsius to degrees Fahrenheit = | 102.2 | "c units^2" | surfaceAreaCylinder) | -| 82 | AP Term Calculation | Find the term number n of the AP series: a1, a2, a3 ... | a-n | arithmeticProgressionTermFunc| -| 83 |"AP Sum Calculation"|"Find the sum of first n terms of the AP series: a1, a2, a3 ..."|"Sum"| arithmeticProgressionSumFunc| -| 84 | Set Operations | Given sets A,B | A^B,A-B,B-A,A U B, | set_operation| - From 51d63a7d656ec5182785f85e6ef53146ab51fdd8 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 21 Oct 2020 14:14:37 -0400 Subject: [PATCH 8/9] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 5306ab5..4f7afde 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ problem, solution = mathgen.genById(0) | Id | Skill | Example problem | Example Solution | Function Name | |------|-----------------------------------|--------------------|-----------------------|--------------------------| [//]: # list start - | 0 | Addition | 16+3= | 19 | subtraction | | 1 | Subtraction | 96-17= | 79 | multiplication | | 2 | Multiplication | 48*1= | 48 | multiplicationFunc) | From 616cc613901b6dadf8e1e5996548bbb99c0031a4 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 21 Oct 2020 14:16:11 -0400 Subject: [PATCH 9/9] Update set_operation.py --- mathgenerator/funcs/set_operation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mathgenerator/funcs/set_operation.py b/mathgenerator/funcs/set_operation.py index 4f0a27a..8d6db07 100644 --- a/mathgenerator/funcs/set_operation.py +++ b/mathgenerator/funcs/set_operation.py @@ -15,3 +15,7 @@ def set_operation(minval=3, maxval=7, n_a=4, n_b=5): problem = "Given the two sets a=" + str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference" solution = "Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is " + str(a.difference(b)) + ",b-a is " + str(b.difference(a)) + ", Symmetric difference is " + str(a.symmetric_difference(b)) return problem, solution + +setoperations = Generator("Union,Intersection,Difference of Two Sets", 93, + "Union,intersection,difference", + "aUb,a^b,a-b,b-a,", set_operation)