mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
yapf update
This commit is contained in:
@@ -4,7 +4,10 @@ import math
|
|||||||
|
|
||||||
def angleBtwVectorsFunc(maxEltAmt=20):
|
def angleBtwVectorsFunc(maxEltAmt=20):
|
||||||
s = 0
|
s = 0
|
||||||
v1 = [round(random.uniform(0, 1000), 2) for i in range(random.randint(2, maxEltAmt))]
|
v1 = [
|
||||||
|
round(random.uniform(0, 1000), 2)
|
||||||
|
for i in range(random.randint(2, maxEltAmt))
|
||||||
|
]
|
||||||
v2 = [round(random.uniform(0, 1000), 2) for i in v1]
|
v2 = [round(random.uniform(0, 1000), 2) for i in v1]
|
||||||
for i in range(len(v1)):
|
for i in range(len(v1)):
|
||||||
s += v1[i] * v2[i]
|
s += v1[i] * v2[i]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ def complexQuadraticFunc(prob_type=0, max_range=10):
|
|||||||
b = random.randrange(1, max_range)
|
b = random.randrange(1, max_range)
|
||||||
c = random.randrange(1, max_range)
|
c = random.randrange(1, max_range)
|
||||||
|
|
||||||
d = (b**2 - 4*a*c)
|
d = (b**2 - 4 * a * c)
|
||||||
else:
|
else:
|
||||||
d = 0
|
d = 0
|
||||||
while d >= 0:
|
while d >= 0:
|
||||||
@@ -22,7 +22,7 @@ def complexQuadraticFunc(prob_type=0, max_range=10):
|
|||||||
b = random.randrange(1, max_range)
|
b = random.randrange(1, max_range)
|
||||||
c = random.randrange(1, max_range)
|
c = random.randrange(1, max_range)
|
||||||
|
|
||||||
d = (b**2 - 4*a*c)
|
d = (b**2 - 4 * a * c)
|
||||||
|
|
||||||
eq = ''
|
eq = ''
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ def complexQuadraticFunc(prob_type=0, max_range=10):
|
|||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
else:
|
else:
|
||||||
s_root1 = round((-b + (d)**0.5)/(2*a), 3)
|
s_root1 = round((-b + (d)**0.5) / (2 * a), 3)
|
||||||
s_root2 = round((-b - (d)**0.5)/(2*a), 3)
|
s_root2 = round((-b - (d)**0.5) / (2 * a), 3)
|
||||||
|
|
||||||
sqrt_d = (d)**0.5
|
sqrt_d = (d)**0.5
|
||||||
|
|
||||||
@@ -69,5 +69,8 @@ def complexQuadraticFunc(prob_type=0, max_range=10):
|
|||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
complex_quadratic = Generator("complex Quadratic Equation", 100, "Find the roots of given Quadratic Equation ",
|
complex_quadratic = Generator(
|
||||||
"simplified solution : (x1, x2), generalized solution : ((-b + sqrt(d))/2a, (-b - sqrt(d))/2a) or ((-b + sqrt(d)i)/2a, (-b - sqrt(d)i)/2a)", complexQuadraticFunc)
|
"complex Quadratic Equation", 100,
|
||||||
|
"Find the roots of given Quadratic Equation ",
|
||||||
|
"simplified solution : (x1, x2), generalized solution : ((-b + sqrt(d))/2a, (-b - sqrt(d))/2a) or ((-b + sqrt(d)i)/2a, (-b - sqrt(d)i)/2a)",
|
||||||
|
complexQuadraticFunc)
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000):
|
|||||||
elif last_value == 4:
|
elif last_value == 4:
|
||||||
solution += (roman_dict[divisor] + roman_dict[divisor * 5])
|
solution += (roman_dict[divisor] + roman_dict[divisor * 5])
|
||||||
elif 5 <= last_value <= 8:
|
elif 5 <= last_value <= 8:
|
||||||
solution += (roman_dict[divisor * 5] + (roman_dict[divisor] * (last_value - 5)))
|
solution += (roman_dict[divisor * 5] + (roman_dict[divisor] *
|
||||||
|
(last_value - 5)))
|
||||||
elif last_value == 9:
|
elif last_value == 9:
|
||||||
solution += (roman_dict[divisor] + roman_dict[divisor * 10])
|
solution += (roman_dict[divisor] + roman_dict[divisor * 10])
|
||||||
x = math.floor(x % divisor)
|
x = math.floor(x % divisor)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ def nthFibonacciNumberFunc(maxN=100):
|
|||||||
golden_ratio = (1 + math.sqrt(5)) / 2
|
golden_ratio = (1 + math.sqrt(5)) / 2
|
||||||
n = random.randint(1, maxN)
|
n = random.randint(1, maxN)
|
||||||
problem = f"What is the {n}th Fibonacci number?"
|
problem = f"What is the {n}th Fibonacci number?"
|
||||||
ans = round((math.pow(golden_ratio, n) - math.pow(-golden_ratio, -n)) / (math.sqrt(5)))
|
ans = round((math.pow(golden_ratio, n) - math.pow(-golden_ratio, -n)) /
|
||||||
|
(math.sqrt(5)))
|
||||||
solution = f"{ans}"
|
solution = f"{ans}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,6 @@ def perimeterOfPolygons(maxSides=12, maxLength=120):
|
|||||||
|
|
||||||
|
|
||||||
perimeter_of_polygons = Generator(
|
perimeter_of_polygons = Generator(
|
||||||
"Perimeter of Polygons", 96, "The perimeter of a x sided polygon with lengths of y cm is: ", "z", perimeterOfPolygons)
|
"Perimeter of Polygons", 96,
|
||||||
|
"The perimeter of a x sided polygon with lengths of y cm is: ", "z",
|
||||||
|
perimeterOfPolygons)
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ def powerOfPowersFunc(maxBase=50, maxPower=10):
|
|||||||
power1=power1,
|
power1=power1,
|
||||||
power2=power2,
|
power2=power2,
|
||||||
step=step)
|
step=step)
|
||||||
solution = str(base ** step)
|
solution = str(base**step)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
power_of_powers = Generator("Power of Powers", 97,
|
power_of_powers = Generator("Power of Powers", 97, "6^4^2 = 6^(4*2) = 6^6",
|
||||||
"6^4^2 = 6^(4*2) = 6^6", "46656", powerOfPowersFunc)
|
"46656", powerOfPowersFunc)
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ def quotientOfPowerSameBaseFunc(maxBase=50, maxPower=10):
|
|||||||
power1=power1,
|
power1=power1,
|
||||||
power2=power2,
|
power2=power2,
|
||||||
step=step)
|
step=step)
|
||||||
solution = str(base ** step)
|
solution = str(base**step)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
quotient_of_power_same_base = Generator("Quotient of Powers with Same Base", 98,
|
quotient_of_power_same_base = Generator("Quotient of Powers with Same Base",
|
||||||
"6^4 / 6^2 = 6^(4-2) = 6^2", "36", quotientOfPowerSameBaseFunc)
|
98, "6^4 / 6^2 = 6^(4-2) = 6^2", "36",
|
||||||
|
quotientOfPowerSameBaseFunc)
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ def quotientOfPowerSamePowerFunc(maxBase=50, maxPower=10):
|
|||||||
base2=base2,
|
base2=base2,
|
||||||
power=power,
|
power=power,
|
||||||
step=step)
|
step=step)
|
||||||
solution = str(step ** power)
|
solution = str(step**power)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
quotient_of_power_same_power = Generator("Quotient of Powers with Same Power", 99,
|
quotient_of_power_same_power = Generator("Quotient of Powers with Same Power",
|
||||||
"6^4 / 3^4 = (6/3)^4 = 2^4", "16", quotientOfPowerSamePowerFunc)
|
99, "6^4 / 3^4 = (6/3)^4 = 2^4", "16",
|
||||||
|
quotientOfPowerSamePowerFunc)
|
||||||
|
|||||||
Reference in New Issue
Block a user