mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* removed asterisk imports from subject inits * import Generator from the right init level
23 lines
616 B
Python
23 lines
616 B
Python
from ...__init__ import Generator
|
|
import random
|
|
|
|
|
|
def gen_func(maxA=25, maxB=25, format='string'):
|
|
a = random.randint(1, maxA)
|
|
b = random.randint(1, maxB)
|
|
|
|
divisor = a * b
|
|
dividend = random.choice([a, b])
|
|
quotient = int(divisor / dividend)
|
|
|
|
if format == 'string':
|
|
return f"{divisor}/{dividend}=", str(quotient)
|
|
elif format == 'latex':
|
|
return ("\\(" + str(divisor) + "\\div" + str(dividend) + "=\\)",
|
|
"\\(" + str(quotient) + "\\)")
|
|
else:
|
|
return divisor, dividend, quotient
|
|
|
|
|
|
division = Generator("Division", 3, gen_func, ["maxA=25", "maxB=25"])
|