Files
mathgenerator/mathgenerator/funcs/basic_math/exponentiation.py
Luke Weiler 8e264e6b23 Remove mathgen (#396)
* Improve generator __init__ function

* Move Generator to new file, remove mathgen

* Remove getGenList redundancies

* Add backwards compatibility import mathgen from

* Insort to genList

* Linter fixes

* Lint fixes
2022-12-19 14:01:52 -05:00

19 lines
532 B
Python

from ...generator import Generator
import random
def gen_func(maxBase=20, maxExpo=10, format='string'):
base = random.randint(1, maxBase)
expo = random.randint(1, maxExpo)
if format == 'string':
return (f"{base}^{expo} =", str(base**expo))
elif format == 'latex':
return f"\\({base}^{{{expo}}}\\)", "\\(" + str(base**expo) + "\\)"
else:
return base, expo, base**expo
exponentiation = Generator("Exponentiation", 53, gen_func,
["maxBase=20", "maxExpo=10"])