mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
fixed lint errors
This commit is contained in:
@@ -13,7 +13,8 @@ def gen_func(maxPrinciple=10000,
|
|||||||
if format == 'string':
|
if format == 'string':
|
||||||
problem = "Compound interest for a principle amount of " + \
|
problem = "Compound interest for a principle amount of " + \
|
||||||
str(p) + " dollars, " + str(r) + \
|
str(p) + " dollars, " + str(r) + \
|
||||||
"% rate of interest and for a time period of " + str(n) + " year is = "
|
"% rate of interest and for a time period of " + \
|
||||||
|
str(n) + " year is = "
|
||||||
return problem, str(a)
|
return problem, str(a)
|
||||||
elif format == 'latex':
|
elif format == 'latex':
|
||||||
return "Latex unavailable"
|
return "Latex unavailable"
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
from .__init__ import *
|
|
||||||
|
|
||||||
|
|
||||||
def gen_func(maxCoordinate=20, minCoordinate=-20, format='string'):
|
|
||||||
def greatest_common_divisor(num1,num2):
|
|
||||||
if num2==0:
|
|
||||||
return num1
|
|
||||||
else:
|
|
||||||
return greatest_common_divisor(num2 , num1%num2)
|
|
||||||
|
|
||||||
x1 = random.randint(minCoordinate, maxCoordinate)
|
|
||||||
x2 = random.randint(minCoordinate, maxCoordinate)
|
|
||||||
|
|
||||||
y1 = random.randint(minCoordinate, maxCoordinate)
|
|
||||||
y2 = random.randint(minCoordinate, maxCoordinate)
|
|
||||||
|
|
||||||
coeff_y = (x2-x1)
|
|
||||||
coeff_x = (y2-y1)
|
|
||||||
constant = y2*coeff_y - x2*coeff_x
|
|
||||||
|
|
||||||
gcd = greatest_common_divisor(abs(coeff_x), abs(coeff_y))
|
|
||||||
|
|
||||||
if gcd !=1:
|
|
||||||
if coeff_y > 0: coeff_y //= gcd
|
|
||||||
if coeff_x > 0: coeff_x //= gcd
|
|
||||||
if constant > 0: constant //= gcd
|
|
||||||
if coeff_y < 0: coeff_y = -(-coeff_y//gcd)
|
|
||||||
if coeff_x < 0: coeff_x = -(-coeff_x//gcd)
|
|
||||||
if constant < 0: constant = -(-constant//gcd)
|
|
||||||
if coeff_y < 0 :
|
|
||||||
coeff_y = -(coeff_y)
|
|
||||||
coeff_x = -(coeff_x)
|
|
||||||
constant = -(constant)
|
|
||||||
|
|
||||||
if format == 'string':
|
|
||||||
problem = f"What is the equation of the line between points ({x1},{y1}) and ({x2},{y2}) in slope-intercept form?"
|
|
||||||
if constant > 0:
|
|
||||||
solution = str(coeff_y)+"y = " + str(coeff_x)+ "x + " + str(constant)
|
|
||||||
else:
|
|
||||||
solution = str(coeff_y)+"y = " + str(coeff_x)+ "x - " + str(-constant)
|
|
||||||
return problem, solution
|
|
||||||
elif format == 'latex':
|
|
||||||
return 'Latex unavailable'
|
|
||||||
else:
|
|
||||||
return x1, x2, y1, y2, coeff_x, coeff_y, constant
|
|
||||||
|
|
||||||
|
|
||||||
equation_of_line_from_two_points = Generator(
|
|
||||||
"Equation of line from two points", 114, gen_func,
|
|
||||||
["maxCoordinate=20", "minCoordinate=-20"])
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from .__init__ import *
|
|||||||
|
|
||||||
def gen_func(format='string'):
|
def gen_func(format='string'):
|
||||||
|
|
||||||
|
|
||||||
if format == 'string':
|
if format == 'string':
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ def gen_func(format='string'):
|
|||||||
# Any variables that go into the problem and solution string without formatting
|
# Any variables that go into the problem and solution string without formatting
|
||||||
return a, b
|
return a, b
|
||||||
|
|
||||||
|
|
||||||
# generator_name should be the same as the file name
|
# generator_name should be the same as the file name
|
||||||
# id can be generated by running nextId.py inside of the scripts folder
|
# replace id with number generated by running nextId.py inside of the scripts folder
|
||||||
# last argument of Generator should be a list of the kwargs used in your gen_func().
|
# last argument of Generator should be a list of the kwargs used in your gen_func().
|
||||||
generator_name = Generator("<Title>", <id>, gen_func,
|
generator_name = Generator("<Title>", id, gen_func,
|
||||||
["<kwarg1>"])
|
["<kwarg1>"])
|
||||||
# Delete all comments before submitting a pr
|
# Delete all comments before submitting a pr
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ else:
|
|||||||
file = './futureGenerators.md'
|
file = './futureGenerators.md'
|
||||||
|
|
||||||
with open(file, 'a') as f:
|
with open(file, 'a') as f:
|
||||||
f.writelines(f'| {title} | {example_problem} | {example_solution} | {further_explanation} |\n')
|
f.writelines(
|
||||||
|
f'| {title} | {example_problem} | {example_solution} | {further_explanation} |\n')
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from makeReadme import main
|
from makeReadme import main
|
||||||
|
|
||||||
|
|
||||||
def get_filepaths(subject_name):
|
def get_filepaths(subject_name):
|
||||||
"""
|
"""
|
||||||
This function will generate the file names in a directory
|
This function will generate the file names in a directory
|
||||||
@@ -23,7 +24,9 @@ def get_filepaths(subject_name):
|
|||||||
|
|
||||||
return file_paths
|
return file_paths
|
||||||
|
|
||||||
subjects = ['algebra', 'basic_math', 'calculus', 'computer_science', 'geometry', 'misc', 'statistics']
|
|
||||||
|
subjects = ['algebra', 'basic_math', 'calculus',
|
||||||
|
'computer_science', 'geometry', 'misc', 'statistics']
|
||||||
for subject in subjects:
|
for subject in subjects:
|
||||||
full_file_paths = get_filepaths(subject)
|
full_file_paths = get_filepaths(subject)
|
||||||
full_file_paths.sort()
|
full_file_paths.sort()
|
||||||
|
|||||||
Reference in New Issue
Block a user