mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Merge pull request #146 from anshitabaid/master
AP series term/sum problem
This commit is contained in:
@@ -84,3 +84,5 @@ from .compoundInterestFunc import *
|
||||
from .deciToHexaFunc import *
|
||||
from .percentageFunc import *
|
||||
from .celsiustofahrenheit import *
|
||||
from .arithmeticProgressionSumFunc import *
|
||||
from .arithmeticProgressionTermFunc import *
|
||||
|
||||
13
mathgenerator/funcs/arithmeticProgressionSumFunc.py
Normal file
13
mathgenerator/funcs/arithmeticProgressionSumFunc.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
|
||||
d = random.randint(-1 * maxd, maxd)
|
||||
a1 = random.randint(-1 * maxa, maxa)
|
||||
a2 = a1 + d
|
||||
a3 = a2 + d
|
||||
n = random.randint(4, maxn)
|
||||
apString = str(a1) + ', ' + str(a2) + ', ' + str(a3) + ' ... '
|
||||
problem = 'Find the sum of first ' + str(n) + ' terms of the AP series: ' + apString
|
||||
solution = n * ((2 * a1) + ((n - 1) * d)) / 2
|
||||
return problem, solution
|
||||
13
mathgenerator/funcs/arithmeticProgressionTermFunc.py
Normal file
13
mathgenerator/funcs/arithmeticProgressionTermFunc.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def arithmeticProgressionTermFunc(maxd=100, maxa=100, maxn=100):
|
||||
d = random.randint(-1 * maxd, maxd)
|
||||
a1 = random.randint(-1 * maxa, maxa)
|
||||
a2 = a1 + d
|
||||
a3 = a2 + d
|
||||
n = random.randint(4, maxn)
|
||||
apString = str(a1) + ', ' + str(a2) + ', ' + str(a3) + ' ... '
|
||||
problem = 'Find the term number ' + str(n) + ' of the AP series: ' + apString
|
||||
solution = a1 + ((n - 1) * d)
|
||||
return problem, solution
|
||||
@@ -268,3 +268,11 @@ decimalToHexadeci = Generator("Decimal to Hexadecimal", 79, "Binary of a=",
|
||||
percentage = Generator("Percentage of a number", 80, "What is a% of b?",
|
||||
"percentage", percentageFunc)
|
||||
celsiustofahrenheit = Generator("Celsius To Fahrenheit", 81, "(C +(9/5))+32=", "F", celsiustofahrenheitFunc)
|
||||
|
||||
arithmeticProgressionTerm = Generator("AP Term Calculation", 82,
|
||||
"Find the term number n of the AP series: a1, a2, a3 ...",
|
||||
"a-n", arithmeticProgressionTermFunc)
|
||||
|
||||
arithmeticProgressionSum = Generator("AP Sum Calculation", 83,
|
||||
"Find the sum of first n terms of the AP series: a1, a2, a3 ...",
|
||||
"Sum", arithmeticProgressionSumFunc)
|
||||
|
||||
Reference in New Issue
Block a user