Fixed createFibList indentation error

This commit is contained in:
lukew3
2020-10-17 14:06:00 -04:00
parent d576c754f6
commit 49ed99a3f9

View File

@@ -713,16 +713,16 @@ def fourthAngleOfQuadriFunc(maxAngle = 180):
problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} =" problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} ="
solution = angle4 solution = angle4
return problem, solution return problem, solution
def quadraticEquation(maxVal=100): def quadraticEquation(maxVal=100):
a = random.randint(1,maxVal) a = random.randint(1,maxVal)
c = random.randint(1,maxVal) c = random.randint(1,maxVal)
b = random.randint(round(math.sqrt(4*a*c))+1,round(math.sqrt(4*maxVal*maxVal))) b = random.randint(round(math.sqrt(4*a*c))+1,round(math.sqrt(4*maxVal*maxVal)))
problem = "Zeros of the Quadratic Equation {}x^2+{}x+{}=0".format(a,b,c) problem = "Zeros of the Quadratic Equation {}x^2+{}x+{}=0".format(a,b,c)
D = math.sqrt(b*b-4*a*c) D = math.sqrt(b*b-4*a*c)
solution = str([round((-b+D)/(2*a), 2),round((-b-D)/(2*a), 2)]) solution = str([round((-b+D)/(2*a), 2),round((-b-D)/(2*a), 2)])
return problem,solution return problem,solution
@@ -797,18 +797,18 @@ def surdsComparisonFunc(maxValue = 100, maxRoot = 10):
elif first < second: elif first < second:
solution = "<" solution = "<"
return problem, solution return problem, solution
def fibonacciSeriesFunc(minNo=1): def fibonacciSeriesFunc(minNo=1):
n = random.randint(minNo,20) n = random.randint(minNo,20)
def createFibList(n): def createFibList(n):
l=[] l=[]
for i in range(n): for i in range(n):
if i<2: if i<2:
l.append(i) l.append(i)
else: else:
val = l[i-1]+l[i-2] val = l[i-1]+l[i-2]
l.append(val) l.append(val)
return l return l
fibList=createFibList(n) fibList=createFibList(n)
problem = "The Fibonacci Series of the first "+str(n)+" numbers is ?" problem = "The Fibonacci Series of the first "+str(n)+" numbers is ?"
solution = fibList solution = fibList
@@ -821,7 +821,7 @@ def basicTrigonometryFunc(angles=[0,30,45,60,90],functions=["sin","cos","tan"]):
problem=f"What is {function}({angle})?" problem=f"What is {function}({angle})?"
expression='math.'+function+'(math.radians(angle))' expression='math.'+function+'(math.radians(angle))'
result_fraction_map={0.0:"0",0.5:"1/2",0.71:"1/√2",0.87:"√3/2",1.0:"1",0.58:"1/√3",1.73:"√3"} result_fraction_map={0.0:"0",0.5:"1/2",0.71:"1/√2",0.87:"√3/2",1.0:"1",0.58:"1/√3",1.73:"√3"}
solution=result_fraction_map[round(eval(expression),2)] if round(eval(expression),2)<=99999 else "" #for handling the ∞ condition solution=result_fraction_map[round(eval(expression),2)] if round(eval(expression),2)<=99999 else "" #for handling the ∞ condition
return problem,solution return problem,solution
@@ -895,4 +895,4 @@ confidenceInterval = Generator("Confidence interval For sample S", 54, "With X%
surdsComparison = Generator("Comparing surds", 55, "Fill in the blanks a^(1/b) _ c^(1/d)", "</>/=", surdsComparisonFunc) 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) 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) 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) sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58, "Sum of angles of polygon with n sides = ", "sum", sumOfAnglesOfPolygonFunc)