mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Added function geometric progression
This commit is contained in:
@@ -899,10 +899,6 @@ def dataSummaryFunc(number_values=15,minval=5,maxval=50):
|
|||||||
var=0
|
var=0
|
||||||
for i in range(number_values):
|
for i in range(number_values):
|
||||||
var+=(random_list[i]-mean)**2
|
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)
|
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)
|
solution="The Mean is {} , Standard Deviation is {}, Variance is {}".format(mean,var/number_values,(var/number_values)**0.5)
|
||||||
return problem,solution
|
return problem,solution
|
||||||
@@ -920,6 +916,30 @@ def volumeSphereFunc(maxRadius = 100):
|
|||||||
ans=(4*math.pi/3)*r*r*r
|
ans=(4*math.pi/3)*r*r*r
|
||||||
solution = f"{ans} m^3"
|
solution = f"{ans} m^3"
|
||||||
return problem,solution
|
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
|
# || Class Instances
|
||||||
|
|
||||||
# Format is:
|
# 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)
|
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)
|
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)
|
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)
|
||||||
Reference in New Issue
Block a user