mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Swapped division and int_division, rounded complex division
This commit is contained in:
@@ -17,7 +17,7 @@ from .lcm import *
|
||||
from .gcd import *
|
||||
from .basic_algebra import *
|
||||
from .log import *
|
||||
from .int_division import *
|
||||
from .complex_division import *
|
||||
from .decimal_to_binary import *
|
||||
from .binary_to_decimal import *
|
||||
from .divide_fractions import *
|
||||
|
||||
15
mathgenerator/funcs/complex_division.py
Normal file
15
mathgenerator/funcs/complex_division.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def complexDivisionFunc(maxRes=99, maxDivid=99):
|
||||
a = random.randint(0, maxDivid)
|
||||
b = random.randint(0, min(maxRes, maxDivid))
|
||||
c = a / b
|
||||
c = round(c, 2)
|
||||
|
||||
problem = str(a) + "/" + str(b) + "="
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
|
||||
|
||||
complex_division = Generator("Complex Division", 13, "a/b=", "c", complexDivisionFunc)
|
||||
@@ -1,14 +1,16 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def divisionFunc(maxRes=99, maxDivid=99):
|
||||
a = random.randint(0, maxDivid)
|
||||
b = random.randint(0, min(maxRes, maxDivid))
|
||||
c = a / b
|
||||
def divisionToIntFunc(maxA=25, maxB=25):
|
||||
a = random.randint(1, maxA)
|
||||
b = random.randint(1, maxB)
|
||||
|
||||
problem = str(a) + "/" + str(b) + "="
|
||||
solution = str(c)
|
||||
divisor = a * b
|
||||
dividend = random.choice([a, b])
|
||||
|
||||
problem = f"{divisor}/{dividend} = "
|
||||
solution = int(divisor / dividend)
|
||||
return problem, solution
|
||||
|
||||
|
||||
division = Generator("Division", 3, "a/b=", "c", divisionFunc)
|
||||
division = Generator("Division", 3, "a/b=", "c", divisionToIntFunc)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def divisionToIntFunc(maxA=25, maxB=25):
|
||||
a = random.randint(1, maxA)
|
||||
b = random.randint(1, maxB)
|
||||
|
||||
divisor = a * b
|
||||
dividend = random.choice([a, b])
|
||||
|
||||
problem = f"{divisor}/{dividend} = "
|
||||
solution = int(divisor / dividend)
|
||||
return problem, solution
|
||||
|
||||
|
||||
int_division = Generator("Easy Division", 13, "a/b=", "c", divisionToIntFunc)
|
||||
Reference in New Issue
Block a user