Swapped division and int_division, rounded complex division

This commit is contained in:
lukew3
2020-11-20 19:44:28 -05:00
parent cda228660c
commit 7543e48f6e
7 changed files with 138 additions and 137 deletions

View File

@@ -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 *

View 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)

View File

@@ -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)

View File

@@ -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)