mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Merge branch 'master' into Ritu1611-patch-2
This commit is contained in:
@@ -370,7 +370,7 @@ def linearEquationsFunc(n = 2, varRange = 20, coeffRange = 20):
|
|||||||
problem = "\n".join(problem)
|
problem = "\n".join(problem)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
def primeFactors(minVal=1, maxVal=200):
|
def primeFactorsFunc(minVal=1, maxVal=200):
|
||||||
a = random.randint(minVal, maxVal)
|
a = random.randint(minVal, maxVal)
|
||||||
n = a
|
n = a
|
||||||
i = 2
|
i = 2
|
||||||
@@ -387,6 +387,36 @@ def primeFactors(minVal=1, maxVal=200):
|
|||||||
solution = f"{factors}"
|
solution = f"{factors}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
def multiplyFractionsFunc(maxVal=10):
|
||||||
|
a = random.randint(1, maxVal)
|
||||||
|
b = random.randint(1, maxVal)
|
||||||
|
c = random.randint(1, maxVal)
|
||||||
|
d = random.randint(1, maxVal)
|
||||||
|
while (a == b):
|
||||||
|
b = random.randint(1, maxVal)
|
||||||
|
while (c == d):
|
||||||
|
d = random.randint(1, maxVal)
|
||||||
|
def calculate_gcd(x, y):
|
||||||
|
while(y):
|
||||||
|
x, y = y, x % y
|
||||||
|
return x
|
||||||
|
tmp_n = a * c
|
||||||
|
tmp_d = b * d
|
||||||
|
gcd = calculate_gcd(tmp_n, tmp_d)
|
||||||
|
x = f"{tmp_n//gcd}/{tmp_d//gcd}"
|
||||||
|
if (tmp_d == 1 or tmp_d == gcd):
|
||||||
|
x = f"{tmp_n//gcd}"
|
||||||
|
problem = f"({a}/{b})*({c}/{d})"
|
||||||
|
solution = x
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
|
def regularPolygonAngleFunc(minVal = 3,maxVal = 20):
|
||||||
|
sideNum = random.randint(minVal, maxVal)
|
||||||
|
problem = f"Find the angle of a regular polygon with {sideNum} sides"
|
||||||
|
exteriorAngle = round((360/sideNum),2)
|
||||||
|
solution = 180 - exteriorAngle
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
def combinationsFunc(maxlength=20):
|
def combinationsFunc(maxlength=20):
|
||||||
def factorial(a):
|
def factorial(a):
|
||||||
d=1
|
d=1
|
||||||
@@ -400,7 +430,6 @@ def combinationsFunc(maxlength=20):
|
|||||||
problem= "Number of combinations from {} objects picked {} at a time ".format(a,b)
|
problem= "Number of combinations from {} objects picked {} at a time ".format(a,b)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
# || Class Instances
|
# || Class Instances
|
||||||
|
|
||||||
#Format is:
|
#Format is:
|
||||||
@@ -433,5 +462,7 @@ systemOfEquations = Generator("Solve a System of Equations in R^2", 23, "2x + 5y
|
|||||||
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)
|
pythagoreanTheorem = Generator("Pythagorean Theorem", 25, "The hypotenuse of a right triangle given the other two lengths a and b = ", "hypotenuse", pythagoreanTheoremFunc)
|
||||||
linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12", "x=-20 & y=12", linearEquationsFunc) #This has multiple variables whereas #23 has only x and y
|
linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12", "x=-20 & y=12", linearEquationsFunc) #This has multiple variables whereas #23 has only x and y
|
||||||
primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =", "[b, c, d, ...]", primeFactors)
|
primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =", "[b, c, d, ...]", primeFactorsFunc)
|
||||||
combinations = Generator("Combinations of Objects",28, "Combinations available for picking 4 objects at a time from 6 distinct objects ="," 15", combinationsFunc)
|
fractionMultiplication = Generator("Fraction Multiplication", 28, "(a/b)*(c/d)=", "x/y", multiplyFractionsFunc)
|
||||||
|
angleRegularPolygon = Generator("Angle of a Regular Polygon",29,"Find the angle of a regular polygon with 6 sides","120",regularPolygonAngleFunc)
|
||||||
|
combinations = Generator("Combinations of Objects",30, "Combinations available for picking 4 objects at a time from 6 distinct objects ="," 15", combinationsFunc)
|
||||||
|
|||||||
Reference in New Issue
Block a user