From 39d9040da26095bca5632b31e25d245c868f8a71 Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Sun, 18 Oct 2020 08:43:41 +0530 Subject: [PATCH 1/8] Added function geometric progression --- mathgenerator/mathgen.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 44218e6..f149213 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -899,10 +899,6 @@ def dataSummaryFunc(number_values=15,minval=5,maxval=50): var=0 for i in range(number_values): var+=(random_list[i]-mean)**2 - print(random_list) - print(mean) - print(var/number_values) - print((var/number_values)**0.5) problem="Find the mean,standard deviation and variance for the data"+str(random_list) solution="The Mean is {} , Standard Deviation is {}, Variance is {}".format(mean,var/number_values,(var/number_values)**0.5) return problem,solution @@ -920,6 +916,30 @@ def volumeSphereFunc(maxRadius = 100): ans=(4*math.pi/3)*r*r*r solution = f"{ans} m^3" return problem,solution + + +def GeomProgrFunc(number_values=6,min_value=2,max_value=12,n_term=7,sum_term=5): + r=random.randint(min_value,max_value) + a=random.randint(min_value,max_value) + n_term=random.randint(number_values,number_values+5) + sum_term=random.randint(number_values,number_values+5) + GP=[] + for i in range(number_values): + GP.append(a*(r**i)) + problem="For the given GP "+str(GP)+" ,Find the value of a,common ratio,"+str(n_term)+"th term value, sum upto "+str(sum_term)+"th term" + value_nth_term=a*(r**(n_term-1)) + sum_till_nth_term=a*((r**sum_term-1)/(r-1)) + solution="The value of a is {}, common ratio is {} , {}th term is {} , sum upto {}th term is {}".format(a,r,n_term,value_nth_term,sum_term,sum_till_nth_term) + return problem,solution + + + + + + + + + # || Class Instances # Format is: @@ -986,3 +1006,4 @@ sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58, "Sum of angles dataSummary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c", "Mean:a+b+c/3,Std,Var", dataSummaryFunc) surfaceAreaSphereGen = Generator("Surface Area of Sphere", 59, "Surface area of sphere with radius = a units is","d units^2", surfaceAreaSphere) volumeSphere=Generator("Volume of Sphere",60,"Volume of sphere with radius r m = ","(4*pi/3)*r*r*r",volumeSphereFunc) +geometricprogression=Generator("Geometric Progression",61,"Initial value,Common Ratio,nth Term,Sum till nth term =","a,r,ar^n-1,sum(ar^n-1",GeomProgrFunc) \ No newline at end of file From 7ae1e3cc1413c26f2dd4a8ac6674967766c935b5 Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Sun, 18 Oct 2020 09:03:00 +0530 Subject: [PATCH 2/8] pylint for GP and Generators part --- mathgenerator/mathgen.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index f149213..67dfa48 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -1000,10 +1000,10 @@ diceSumProbability=Generator("Probability of a certain sum appearing on faces of exponentiation = Generator("Exponentiation", 53,"a^b = ","c",exponentiationFunc) confidenceInterval = Generator("Confidence interval For sample S", 54, "With X% confidence", "is (A,B)", confidenceIntervalFunc) surdsComparison = Generator("Comparing surds", 55, "Fill in the blanks a^(1/b) _ c^(1/d)", "/=", surdsComparisonFunc) -fibonacciSeries = Generator("Fibonacci Series",56,"fibonacci series of first a numbers","prints the fibonacci series starting from 0 to a",fibonacciSeriesFunc) -basicTrigonometry=Generator("Trigonometric Values",57,"What is sin(X)?","ans",basicTrigonometryFunc) +fibonacciSeries = Generator("Fibonacci Series", 56, "fibonacci series of first a numbers", "prints the fibonacci series starting from 0 to a", fibonacciSeriesFunc) +basicTrigonometry=Generator("Trigonometric Values", 57, "What is sin(X)?", "ans", basicTrigonometryFunc) sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58, "Sum of angles of polygon with n sides = ", "sum", sumOfAnglesOfPolygonFunc) dataSummary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c", "Mean:a+b+c/3,Std,Var", dataSummaryFunc) -surfaceAreaSphereGen = Generator("Surface Area of Sphere", 59, "Surface area of sphere with radius = a units is","d units^2", surfaceAreaSphere) -volumeSphere=Generator("Volume of Sphere",60,"Volume of sphere with radius r m = ","(4*pi/3)*r*r*r",volumeSphereFunc) -geometricprogression=Generator("Geometric Progression",61,"Initial value,Common Ratio,nth Term,Sum till nth term =","a,r,ar^n-1,sum(ar^n-1",GeomProgrFunc) \ No newline at end of file +surfaceAreaSphereGen = Generator("Surface Area of Sphere", 59, "Surface area of sphere with radius = a units is", "d units^2", surfaceAreaSphere) +volumeSphere=Generator("Volume of Sphere", 60, "Volume of sphere with radius r m = ", "(4*pi/3)*r*r*r", volumeSphereFunc) +geometricprogression=Generator("Geometric Progression", 61, "Initial value,Common Ratio,nth Term,Sum till nth term =", "a,r,ar^n-1,sum(ar^n-1", GeomProgrFunc) \ No newline at end of file From 3ac7236ea652b456bac9919254dda11c0531d909 Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Sun, 18 Oct 2020 09:06:03 +0530 Subject: [PATCH 3/8] trying out lint --- mathgenerator/mathgen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 67dfa48..647c1df 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -1,3 +1,4 @@ +# for lint import random import math import fractions @@ -918,7 +919,7 @@ def volumeSphereFunc(maxRadius = 100): return problem,solution -def GeomProgrFunc(number_values=6,min_value=2,max_value=12,n_term=7,sum_term=5): +def GeomProgrFunc(number_values=6, min_value=2, max_value=12, n_term=7, sum_term=5): r=random.randint(min_value,max_value) a=random.randint(min_value,max_value) n_term=random.randint(number_values,number_values+5) From c94a59604220b660f22da5e248d15dd1e23fdcd0 Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Sun, 18 Oct 2020 09:09:16 +0530 Subject: [PATCH 4/8] flake8 comments --- mathgenerator/mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 647c1df..e4d5e3a 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -1,4 +1,4 @@ -# for lint + # for lint import random import math import fractions From 716c3666f157c89ea6869087d71140b1cd3cb66f Mon Sep 17 00:00:00 2001 From: NarayanAdithya Date: Sun, 18 Oct 2020 09:15:21 +0530 Subject: [PATCH 5/8] Flake for 797+ lines --- mathgenerator/mathgen.py | 41 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index e4d5e3a..b2d7837 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -1,4 +1,3 @@ - # for lint import random import math import fractions @@ -79,7 +78,7 @@ def binaryComplement1sFunc(maxDigits=10): question += temp answer += "0" if temp == "1" else "1" - problem = question+"=" + problem = question + "=" solution = answer return problem, solution @@ -783,6 +782,7 @@ def quadraticEquation(maxVal=100): solution = str([round((-b + D) / (2 * a), 2), round((-b - D) / (2 * a), 2)]) return problem, solution + def hcfFunc(maxVal=20): a = random.randint(1, maxVal) b = random.randint(1, maxVal) @@ -793,25 +793,26 @@ def hcfFunc(maxVal=20): solution = str(x) return problem, solution + def DiceSumProbFunc(maxDice=3): - a = random.randint(1,maxDice) - b = random.randint(a,6*a) - count=0 - for i in [1,2,3,4,5,6]: - if a==1: - if i==b: - count=count+1 - elif a==2: - for j in [1,2,3,4,5,6]: - if i+j==b: - count=count+1 - elif a==3: - for j in [1,2,3,4,5,6]: - for k in [1,2,3,4,5,6]: - if i+j+k==b: - count=count+1 - problem = "If {} dice are rolled at the same time, the probability of getting a sum of {} =".format(a,b) - solution="{}/{}".format(count, 6**a) + a = random.randint(1, maxDice) + b = random.randint(a, 6 * a) + count = 0 + for i in [1, 2, 3, 4, 5, 6]: + if a == 1: + if i == b: + count = count + 1 + elif a == 2 : + for j in [1, 2, 3, 4, 5, 6]: + if i + j == b: + count= count + 1 + elif a == 3: + for j in [1, 2, 3, 4, 5, 6]: + for k in [1, 2, 3, 4, 5, 6]: + if i + j + k == b: + count= count + 1 + problem = "If {} dice are rolled at the same time, the probability of getting a sum of {} =".format(a, b) + solution="{}/{}".format(count, 6 ** a) return problem, solution def exponentiationFunc(maxBase = 20,maxExpo = 10): From 26173e3dc9a3396e7849f1612155465e27a7d570 Mon Sep 17 00:00:00 2001 From: NarayanAdithya <57533346+NarayanAdithya@users.noreply.github.com> Date: Sun, 18 Oct 2020 09:24:47 +0530 Subject: [PATCH 6/8] Update Readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7643a53..7034023 100644 --- a/README.md +++ b/README.md @@ -117,3 +117,4 @@ problem, solution = mathgen.genById(0) | 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[38, 29, 43, 25, 7, 10, 13, 14, 43, 44, 30, 42, 48, 48, 42] | The Mean is 31.733333333333334 , Standard Deviation is 199.26222222222222, Variance is 14.116027140177303 | dataSummary | | 59 | Surface Area of Sphere | Surface area of Sphere with radius = 13m is | 2123.7166338267 m^2 | surfaceAreaSphereGen | | 60 | Volume of Sphere | Volume of sphere with radius 84 m = | 2482712.7095377133 m^3 | volumeSphere | +| 61 | Geometric Progression | Given [2,4,8] find a,r,4th term, sum to 3rd term| 2,2,16,14 | GeomProgrFunc From 0d4387c7cda7251e4e027eebc49ca5949e55a277 Mon Sep 17 00:00:00 2001 From: NarayanAdithya <57533346+NarayanAdithya@users.noreply.github.com> Date: Sun, 18 Oct 2020 09:25:12 +0530 Subject: [PATCH 7/8] Update Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7034023..342105f 100644 --- a/README.md +++ b/README.md @@ -117,4 +117,4 @@ problem, solution = mathgen.genById(0) | 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[38, 29, 43, 25, 7, 10, 13, 14, 43, 44, 30, 42, 48, 48, 42] | The Mean is 31.733333333333334 , Standard Deviation is 199.26222222222222, Variance is 14.116027140177303 | dataSummary | | 59 | Surface Area of Sphere | Surface area of Sphere with radius = 13m is | 2123.7166338267 m^2 | surfaceAreaSphereGen | | 60 | Volume of Sphere | Volume of sphere with radius 84 m = | 2482712.7095377133 m^3 | volumeSphere | -| 61 | Geometric Progression | Given [2,4,8] find a,r,4th term, sum to 3rd term| 2,2,16,14 | GeomProgrFunc +| 61 | Geometric Progression | Given [2,4,8] find a,r,4th term, sum to 3rd term| 2,2,16,14 | GeomProgrFunc | From de1f4c4c1f2a6eca0e85d1e4416bd49cd4fe4141 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Sun, 18 Oct 2020 22:05:47 -0400 Subject: [PATCH 8/8] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 342105f..7643a53 100644 --- a/README.md +++ b/README.md @@ -117,4 +117,3 @@ problem, solution = mathgen.genById(0) | 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[38, 29, 43, 25, 7, 10, 13, 14, 43, 44, 30, 42, 48, 48, 42] | The Mean is 31.733333333333334 , Standard Deviation is 199.26222222222222, Variance is 14.116027140177303 | dataSummary | | 59 | Surface Area of Sphere | Surface area of Sphere with radius = 13m is | 2123.7166338267 m^2 | surfaceAreaSphereGen | | 60 | Volume of Sphere | Volume of sphere with radius 84 m = | 2482712.7095377133 m^3 | volumeSphere | -| 61 | Geometric Progression | Given [2,4,8] find a,r,4th term, sum to 3rd term| 2,2,16,14 | GeomProgrFunc |