This commit is contained in:
lukew3
2020-10-19 12:18:28 -04:00
5 changed files with 26 additions and 1 deletions

View File

@@ -80,3 +80,5 @@ from .matrixInversion import *
from .sectorAreaFunc import*
from .meanMedianFunc import*
from .determinantToMatrix22 import *
from .compoundInterestFunc import *
from .deciToHexaFunc import *

View File

@@ -0,0 +1,11 @@
from .__init__ import *
def compoundInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10, maxPeriod = 10):
p = random.randint(100, maxPrinciple)
r = random.randint(1, maxRate)
t = random.randint(1, maxTime)
n = random.randint(1, maxPeriod)
A = p * ((1 + (r/(100*n))**(n*t)))
problem = "Compound Interest for a principle amount of " + str(p) + " dollars, " + str(r) + "% rate of interest and for a time period of " + str(t) + " compounded monthly is = "
solution = round(A, 2)
return problem, solution

View File

@@ -0,0 +1,10 @@
from .__init__ import *
def deciToHexaFunc(max_dec=1000):
a = random.randint(0, max_dec)
b = hex(a)
problem = "Binary of " + str(a) + "="
solution = str(b)
return problem, solution

View File

@@ -113,3 +113,5 @@ invertmatrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is",
sectorArea=Generator("Area of a Sector", 75,"Area of a sector with radius, r and angle, a ","Area",sectorAreaFunc)
meanMedian=Generator("Mean and Median", 76,"Mean and median of given set of numbers","Mean, Median",meanMedianFunc)
intMatrix22determinant = Generator("Determinant to 2x2 Matrix", 77, "Det([[a,b],[c,d]]) =", " a * d - b * c", determinantToMatrix22)
compoundInterest = Generator("Compound Interest", 78, "Compound interest for a principle amount of p dollars, r% rate of interest and for a time period of t years with n times compounded annually is = ", "A dollars", compoundInterestFunc)
decimalToHexadeci = Generator("Decimal to Hexadecimal", 79,"Binary of a=", "b", deciToHexaFunc)

View File

@@ -3,4 +3,4 @@ from mathgenerator import mathgen
#test your generators here
print(mathgen.addition())
print(mathgen.genById(10))
print(mathgen.genById(79))