mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* 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
19 lines
532 B
Python
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"])
|