mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Move files to subject folders
This commit is contained in:
29
mathgenerator/funcs/algebra/basic_algebra.py
Normal file
29
mathgenerator/funcs/algebra/basic_algebra.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def basicAlgebraFunc(maxVariable=10):
|
||||
a = random.randint(1, maxVariable)
|
||||
b = random.randint(1, maxVariable)
|
||||
c = random.randint(b, maxVariable)
|
||||
|
||||
# calculate gcd
|
||||
def calculate_gcd(x, y):
|
||||
while (y):
|
||||
x, y = y, x % y
|
||||
return x
|
||||
|
||||
i = calculate_gcd((c - b), a)
|
||||
x = f"{(c - b)//i}/{a//i}"
|
||||
|
||||
if (c - b == 0):
|
||||
x = "0"
|
||||
elif a == 1 or a == i:
|
||||
x = f"{c - b}"
|
||||
|
||||
problem = f"{a}x + {b} = {c}"
|
||||
solution = x
|
||||
return problem, solution
|
||||
|
||||
|
||||
basic_algebra = Generator("Basic Algebra", 11, "ax + b = c", "d",
|
||||
basicAlgebraFunc)
|
||||
Reference in New Issue
Block a user