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