mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
21 lines
499 B
Python
21 lines
499 B
Python
from .__init__ import *
|
|
|
|
|
|
def squareFunc(maxSquareNum=20, format='string'):
|
|
a = random.randint(1, maxSquareNum)
|
|
b = a * a
|
|
|
|
if format == 'string':
|
|
problem = str(a) + "^2" + "="
|
|
solution = str(b)
|
|
return problem, solution
|
|
if format == 'latex':
|
|
problem = "\\(" + str(a) + "^{2}=\\)"
|
|
solution = "\\(" + str(b) + "\\)"
|
|
return problem, solution
|
|
else:
|
|
return a, b
|
|
|
|
|
|
square = Generator("Square", 8, squareFunc, ["maxSquareNum=20"])
|