From b1a06816dd44432f51c39059d2c7379a069a1252 Mon Sep 17 00:00:00 2001 From: helplessThor <66440538+helplessThor@users.noreply.github.com> Date: Sat, 17 Oct 2020 15:11:18 +0530 Subject: [PATCH] Update mathgen.py Compound Interest added --- mathgenerator/mathgen.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1041a55..f986d76 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -637,6 +637,15 @@ def simpleInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10): problem = "Simple interest for a principle amount of " + str(a) +" dollars, " + str(b) + "% rate of interest and for a time period of " + str(c) + " years is = " solution = round(d, 2) return problem, solution +def compoundInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10, maxPeriod = ): + 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 def matrixMultiplicationFunc(maxVal=100): m= random.randint(2, 10)