mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* import with name not *, remove top level imports * Fix linter, remove numpy * Lint fixes * Comment worksheet generator temporarily
23 lines
600 B
Python
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"])
|