Merge pull request #84 from ananyakaushik/pythagoras

add Pythagorean theorem
This commit is contained in:
Luke Weiler
2020-10-16 09:53:40 -04:00
committed by GitHub

View File

@@ -339,6 +339,14 @@ def distanceTwoPointsFunc(maxValXY = 20, minValXY=-20):
problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})" problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})"
return problem, solution return problem, solution
def pythagoreanTheoremFunc(maxLength = 20):
a = random.randint(1, maxLength)
b = random.randint(1, maxLength)
c = (a**2 + b**2)**0.5
problem = f"The hypotenuse of a right triangle given the other two lengths {a} and {b} = "
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
return problem, solution
# || Class Instances # || Class Instances
#Format is: #Format is:
@@ -368,4 +376,5 @@ factoring = Generator("Subtraction", 21, "x^2+(x1+x2)+x1*x2", "(x-x1)(x-x2)", fa
thirdAngleOfTriangle = Generator("Third Angle of Triangle", 22, "Third Angle of the triangle = ", "angle3", thirdAngleOfTriangleFunc) thirdAngleOfTriangle = Generator("Third Angle of Triangle", 22, "Third Angle of the triangle = ", "angle3", thirdAngleOfTriangleFunc)
systemOfEquations = Generator("Solve a System of Equations in R^2", 23, "2x + 5y = 13, -3x - 3y = -6", "x = -1, y = 3", systemOfEquations = Generator("Solve a System of Equations in R^2", 23, "2x + 5y = 13, -3x - 3y = -6", "x = -1, y = 3",
systemOfEquationsFunc) systemOfEquationsFunc)
distance2Point = Generator("Distance between 2 points", 24, "Find the distance between (x1,y1) and (x2,y2)","sqrt(distanceSquared)", distanceTwoPointsFunc) distance2Point = Generator("Distance between 2 points", 24, "Find the distance between (x1,y1) and (x2,y2)","sqrt(distanceSquared)", distanceTwoPointsFunc)
pythagoreanTheorem = Generator("Pythagorean Theorem", 25, "The hypotenuse of a right triangle given the other two lengths a and b = ", "hypotenuse", pythagoreanTheoremFunc)