mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
23 lines
612 B
Python
23 lines
612 B
Python
from .__init__ import *
|
|
|
|
|
|
def multiplicationFunc(maxRes=99, maxMulti=99, style='raw'):
|
|
a = random.randint(0, maxMulti)
|
|
if a == 0:
|
|
b = random.randint(0, maxRes)
|
|
else:
|
|
b = random.randint(0, min(int(maxMulti / a), maxRes))
|
|
c = a * b
|
|
|
|
if style == 'latex':
|
|
problem = "\\(" + str(a) + "\cdot" + str(b) + "=\\)"
|
|
solution = "\\(" + str(c) + "\\)"
|
|
else:
|
|
problem = str(a) + "*" + str(b) + "="
|
|
solution = str(c)
|
|
return problem, solution
|
|
|
|
|
|
multiplication = Generator("Multiplication", 2, "a*b=", "c",
|
|
multiplicationFunc)
|