Split AP into 2 funcs and reorganized

This commit is contained in:
Anshita
2020-10-20 00:44:41 +05:30
parent e122168468
commit ddc42a5638
4 changed files with 6 additions and 2 deletions

View File

@@ -84,3 +84,5 @@ from .compoundInterestFunc import *
from .deciToHexaFunc import * from .deciToHexaFunc import *
from .percentageFunc import * from .percentageFunc import *
from .celsiustofahrenheit import * from .celsiustofahrenheit import *
from .arithmeticProgressionSumFunc import *
from .arithmeticProgressionTermFunc import *

View File

@@ -1,5 +1,6 @@
from .__init__ import * from .__init__ import *
def arithmeticProgressionSumFunc (maxd = 100, maxa = 100, maxn = 100): def arithmeticProgressionSumFunc (maxd = 100, maxa = 100, maxn = 100):
d = random.randint (-1 * maxd, maxd) d = random.randint (-1 * maxd, maxd)
a1 = random.randint (-1 * maxa, maxa) a1 = random.randint (-1 * maxa, maxa)

View File

@@ -1,5 +1,6 @@
from .__init__ import * from .__init__ import *
def arithmeticProgressionTermFunc (maxd = 100, maxa = 100, maxn = 100): def arithmeticProgressionTermFunc (maxd = 100, maxa = 100, maxn = 100):
d = random.randint (-1 * maxd, maxd) d = random.randint (-1 * maxd, maxd)
a1 = random.randint (-1 * maxa, maxa) a1 = random.randint (-1 * maxa, maxa)
@@ -9,4 +10,4 @@ def arithmeticProgressionTermFunc (maxd = 100, maxa = 100, maxn = 100):
apString = str(a1) +', ' + str(a2) +', ' + str(a3) + ' ... ' apString = str(a1) +', ' + str(a2) +', ' + str(a3) + ' ... '
problem = 'Find the term number ' + str(n) + ' of the AP series: ' + apString problem = 'Find the term number ' + str(n) + ' of the AP series: ' + apString
solution = a1 + ((n-1)*d) solution = a1 + ((n-1)*d)
return problen, solution return problem, solution

View File

@@ -275,4 +275,4 @@ arithmeticProgressionTerm = Generator ("AP Term Calculation", 82,
arithmeticProgressionSum = Generator ("AP Sum Calculation", 83, arithmeticProgressionSum = Generator ("AP Sum Calculation", 83,
"Find the sum of first n terms of the AP series: a1, a2, a3 ...", "Find the sum of first n terms of the AP series: a1, a2, a3 ...",
"Sum", arithmeticProgressionSumFunc) "Sum", arithmeticProgressionSumFunc)