Files
mathgenerator/mathgenerator/funcs/calculus/power_rule_integration.py
Luke Weiler 20d3294a93 Remove asterisk imports from subject inits (#391)
* removed asterisk imports from subject inits

* import Generator from the right init level
2022-12-19 02:06:10 -05:00

37 lines
983 B
Python

from ...__init__ import Generator
import random
def gen_func(maxCoef=10,
maxExp=10,
maxTerms=5,
format='string'):
numTerms = random.randint(1, maxTerms)
problem = ""
solution = ""
for i in range(numTerms):
if i > 0:
problem += " + "
solution += " + "
coefficient = random.randint(1, maxCoef)
exponent = random.randint(1, maxExp)
problem += str(coefficient) + "x^" + str(exponent)
solution += "(" + str(coefficient) + "/" + \
str(exponent) + ")x^" + str(exponent + 1)
solution += " + c"
if format == 'string':
return problem, solution
elif format == 'latex':
return "Latex unavailable"
else:
return problem, solution
power_rule_integration = Generator("Power Rule Integration", 48,
gen_func,
["maxCoef=10", "maxExp=10", "maxTerms=5"])