Files
mathgenerator/mathgenerator/funcs/algebra/log.py
Luke Weiler f2efb3751d import with name not asterisk
* import with name not *, remove top level imports

* Fix linter, remove numpy

* Lint fixes

* Comment worksheet generator temporarily
2022-12-19 01:31:08 -05:00

23 lines
600 B
Python

from ..__init__ import Generator
import random
def gen_func(maxBase=3, maxVal=8, format='string'):
a = random.randint(1, maxVal)
b = random.randint(2, maxBase)
c = pow(b, a)
if format == 'string':
problem = "log" + str(b) + "(" + str(c) + ")"
solution = str(a)
return problem, solution
elif format == 'latex':
problem = "\\(\\log_{" + str(b) + "}" + str(c) + "\\)"
solution = "\\(" + str(a) + "\\)"
return problem, solution
else:
return b, c, a
log = Generator("Logarithm", 12, gen_func, ["maxBase=3", "maxVal=8"])