mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
23 lines
693 B
Python
23 lines
693 B
Python
from .__init__ import *
|
|
|
|
|
|
def addition_func(maxSum=99, maxAddend=50, style='raw'):
|
|
if maxAddend > maxSum:
|
|
maxAddend = maxSum
|
|
a = random.randint(0, maxAddend)
|
|
# The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well
|
|
b = random.randint(0, min((maxSum - a), maxAddend))
|
|
c = a + b
|
|
|
|
if style == 'latex':
|
|
problem = "\\(" + str(a) + '+' + str(b) + "\\)"
|
|
solution = str(c)
|
|
return problem, solution
|
|
else:
|
|
problem = str(a) + "+" + str(b) + "="
|
|
solution = str(c)
|
|
return problem, solution
|
|
|
|
|
|
addition = Generator("Addition", 0, "a+b=", "c", addition_func)
|