mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Merge branch 'adithya' of https://github.com/NarayanAdithya/mathgenerator into adithya
This commit is contained in:
@@ -3,3 +3,4 @@ hypothesis
|
|||||||
flake8
|
flake8
|
||||||
autopep8
|
autopep8
|
||||||
sympy
|
sympy
|
||||||
|
numpy
|
||||||
|
|||||||
@@ -20,4 +20,5 @@ class Generator:
|
|||||||
|
|
||||||
|
|
||||||
def getGenList():
|
def getGenList():
|
||||||
return genList
|
correctedList = genList[-1:] + genList[:-1]
|
||||||
|
return correctedList
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def BinaryToDecimalFunc(max_dig=10):
|
def BinaryToDecimalFunc(max_dig=10):
|
||||||
@@ -10,3 +11,7 @@ def BinaryToDecimalFunc(max_dig=10):
|
|||||||
|
|
||||||
solution = int(problem, 2)
|
solution = int(problem, 2)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
binaryToDecimal = Generator("Binary to Decimal", 15, "Decimal of a=", "b",
|
||||||
|
BinaryToDecimalFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def DecimalToBinaryFunc(max_dec=99):
|
def DecimalToBinaryFunc(max_dec=99):
|
||||||
@@ -9,3 +10,7 @@ def DecimalToBinaryFunc(max_dec=99):
|
|||||||
solution = str(b)
|
solution = str(b)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
decimalToBinary = Generator("Decimal to Binary", 14, "Binary of a=", "b",
|
||||||
|
DecimalToBinaryFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def DiceSumProbFunc(maxDice=3):
|
def DiceSumProbFunc(maxDice=3):
|
||||||
@@ -24,3 +25,9 @@ def DiceSumProbFunc(maxDice=3):
|
|||||||
a, b)
|
a, b)
|
||||||
solution = "{}/{}".format(count, 6**a)
|
solution = "{}/{}".format(count, 6**a)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
diceSumProbability = Generator(
|
||||||
|
"Probability of a certain sum appearing on faces of dice", 52,
|
||||||
|
"If n dices are rolled then probabilty of getting sum of x is =", "z",
|
||||||
|
DiceSumProbFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def MidPointOfTwoPointFunc(maxValue=20):
|
def MidPointOfTwoPointFunc(maxValue=20):
|
||||||
@@ -10,3 +11,8 @@ def MidPointOfTwoPointFunc(maxValue=20):
|
|||||||
problem = f"({x1},{y1}),({x2},{y2})="
|
problem = f"({x1},{y1}),({x2},{y2})="
|
||||||
solution = f"({(x1+x2)/2},{(y1+y2)/2})"
|
solution = f"({(x1+x2)/2},{(y1+y2)/2})"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
midPointOfTwoPoint = Generator("Midpoint of the two point", 20,
|
||||||
|
"((X1,Y1),(X2,Y2))=", "((X1+X2)/2,(Y1+Y2)/2)",
|
||||||
|
MidPointOfTwoPointFunc)
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ from .moduloFunc import *
|
|||||||
from .squareRootFunc import *
|
from .squareRootFunc import *
|
||||||
from .powerRuleDifferentiationFunc import *
|
from .powerRuleDifferentiationFunc import *
|
||||||
from .squareFunc import *
|
from .squareFunc import *
|
||||||
from .gcdFunc import *
|
|
||||||
from .lcmFunc import *
|
from .lcmFunc import *
|
||||||
|
from .gcdFunc import *
|
||||||
from .basicAlgebraFunc import *
|
from .basicAlgebraFunc import *
|
||||||
from .logFunc import *
|
from .logFunc import *
|
||||||
from .divisionToIntFunc import *
|
from .divisionToIntFunc import *
|
||||||
@@ -35,10 +35,10 @@ from .regularPolygonAngleFunc import *
|
|||||||
from .combinationsFunc import *
|
from .combinationsFunc import *
|
||||||
from .factorialFunc import *
|
from .factorialFunc import *
|
||||||
from .surfaceAreaCube import *
|
from .surfaceAreaCube import *
|
||||||
from .volumeCube import *
|
|
||||||
from .surfaceAreaCuboid import *
|
from .surfaceAreaCuboid import *
|
||||||
from .volumeCuboid import *
|
|
||||||
from .surfaceAreaCylinder import *
|
from .surfaceAreaCylinder import *
|
||||||
|
from .volumeCube import *
|
||||||
|
from .volumeCuboid import *
|
||||||
from .volumeCylinder import *
|
from .volumeCylinder import *
|
||||||
from .surfaceAreaCone import *
|
from .surfaceAreaCone import *
|
||||||
from .volumeCone import *
|
from .volumeCone import *
|
||||||
@@ -84,5 +84,9 @@ 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 *
|
from .arithmeticProgressionTermFunc import *
|
||||||
|
from .arithmeticProgressionSumFunc import *
|
||||||
|
from .decimalToOctalFunc import *
|
||||||
|
from .decimalToRomanNumeralsFunc import *
|
||||||
|
from .degreeToRadFunc import *
|
||||||
|
from .radianToDegFunc import *
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def absoluteDifferenceFunc(maxA=100, maxB=100):
|
def absoluteDifferenceFunc(maxA=100, maxB=100):
|
||||||
@@ -10,3 +11,9 @@ def absoluteDifferenceFunc(maxA=100, maxB=100):
|
|||||||
str(a) + " and " + str(b) + " = "
|
str(a) + " and " + str(b) + " = "
|
||||||
solution = absDiff
|
solution = absDiff
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
absoluteDifference = Generator(
|
||||||
|
"Absolute difference between two numbers", 71,
|
||||||
|
"Absolute difference betweeen two numbers a and b =", "|a-b|",
|
||||||
|
absoluteDifferenceFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def angleBtwVectorsFunc(maxEltAmt=20):
|
def angleBtwVectorsFunc(maxEltAmt=20):
|
||||||
@@ -19,3 +20,9 @@ def angleBtwVectorsFunc(maxEltAmt=20):
|
|||||||
solution = 'NaN'
|
solution = 'NaN'
|
||||||
# would return the answer in radians
|
# would return the answer in radians
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
angleBtwVectors = Generator(
|
||||||
|
"Angle between 2 vectors", 70,
|
||||||
|
"Angle Between 2 vectors V1=[v11, v12, ..., v1n] and V2=[v21, v22, ....., v2n]",
|
||||||
|
"V1.V2 / (euclidNorm(V1)*euclidNorm(V2))", angleBtwVectorsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
||||||
@@ -13,3 +14,8 @@ def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
|||||||
str(a) + " " + str(b) + " " + str(c) + " = "
|
str(a) + " " + str(b) + " " + str(c) + " = "
|
||||||
solution = area
|
solution = area
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
areaOfTriangle = Generator("Area of Triangle", 18,
|
||||||
|
"Area of Triangle with side lengths a, b, c = ",
|
||||||
|
"area", areaOfTriangleFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
|
def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
|
||||||
@@ -11,3 +12,8 @@ def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
|
|||||||
problem = 'Find the sum of first ' + str(n) + ' terms of the AP series: ' + apString
|
problem = 'Find the sum of first ' + str(n) + ' terms of the AP series: ' + apString
|
||||||
solution = n * ((2 * a1) + ((n - 1) * d)) / 2
|
solution = n * ((2 * a1) + ((n - 1) * d)) / 2
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
arithmeticProgressionSum = Generator("AP Sum Calculation", 83,
|
||||||
|
"Find the sum of first n terms of the AP series: a1, a2, a3 ...",
|
||||||
|
"Sum", arithmeticProgressionSumFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def arithmeticProgressionTermFunc(maxd=100, maxa=100, maxn=100):
|
def arithmeticProgressionTermFunc(maxd=100, maxa=100, maxn=100):
|
||||||
@@ -11,3 +12,8 @@ def arithmeticProgressionTermFunc(maxd=100, maxa=100, maxn=100):
|
|||||||
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 problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
arithmeticProgressionTerm = Generator("AP Term Calculation", 82,
|
||||||
|
"Find the term number n of the AP series: a1, a2, a3 ...",
|
||||||
|
"a-n", arithmeticProgressionTermFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def basicAlgebraFunc(maxVariable=10):
|
def basicAlgebraFunc(maxVariable=10):
|
||||||
@@ -23,3 +24,7 @@ def basicAlgebraFunc(maxVariable=10):
|
|||||||
problem = f"{a}x + {b} = {c}"
|
problem = f"{a}x + {b} = {c}"
|
||||||
solution = x
|
solution = x
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
basicAlgebra = Generator("Basic Algebra", 11, "ax + b = c", "d",
|
||||||
|
basicAlgebraFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
# Handles degrees in quadrant one
|
# Handles degrees in quadrant one
|
||||||
@@ -23,3 +24,7 @@ def basicTrigonometryFunc(angles=[0, 30, 45, 60, 90],
|
|||||||
solution = result_fraction_map[round(eval(expression), 2)] if round(
|
solution = result_fraction_map[round(eval(expression), 2)] if round(
|
||||||
eval(expression), 2) <= 99999 else "∞" # for handling the ∞ condition
|
eval(expression), 2) <= 99999 else "∞" # for handling the ∞ condition
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
basicTrigonometry = Generator("Trigonometric Values", 57, "What is sin(X)?",
|
||||||
|
"ans", basicTrigonometryFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def binary2sComplementFunc(maxDigits=10):
|
def binary2sComplementFunc(maxDigits=10):
|
||||||
@@ -26,3 +27,8 @@ def binary2sComplementFunc(maxDigits=10):
|
|||||||
problem = "2's complement of " + question + " ="
|
problem = "2's complement of " + question + " ="
|
||||||
solution = ''.join(answer).lstrip('0')
|
solution = ''.join(answer).lstrip('0')
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
binary2sComplement = Generator("Binary 2's Complement", 73,
|
||||||
|
"2's complement of 11010110 =", "101010",
|
||||||
|
binary2sComplementFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def binaryComplement1sFunc(maxDigits=10):
|
def binaryComplement1sFunc(maxDigits=10):
|
||||||
@@ -13,3 +14,7 @@ def binaryComplement1sFunc(maxDigits=10):
|
|||||||
problem = question + "="
|
problem = question + "="
|
||||||
solution = answer
|
solution = answer
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
binaryComplement1s = Generator("Binary Complement 1s", 4, "1010=", "0101",
|
||||||
|
binaryComplement1sFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def binaryToHexFunc(max_dig=10):
|
def binaryToHexFunc(max_dig=10):
|
||||||
@@ -9,3 +10,7 @@ def binaryToHexFunc(max_dig=10):
|
|||||||
|
|
||||||
solution = hex(int(problem, 2))
|
solution = hex(int(problem, 2))
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
binaryToHex = Generator("Binary to Hexidecimal", 64, "Hexidecimal of a=", "b",
|
||||||
|
binaryToHexFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def combinationsFunc(maxlength=20):
|
def combinationsFunc(maxlength=20):
|
||||||
@@ -17,3 +18,9 @@ def combinationsFunc(maxlength=20):
|
|||||||
a, b)
|
a, b)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
combinations = Generator(
|
||||||
|
"Combinations of Objects", 30,
|
||||||
|
"Combinations available for picking 4 objects at a time from 6 distinct objects =",
|
||||||
|
" 15", combinationsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def commonFactorsFunc(maxVal=100):
|
def commonFactorsFunc(maxVal=100):
|
||||||
@@ -22,3 +23,8 @@ def commonFactorsFunc(maxVal=100):
|
|||||||
problem = f"Common Factors of {a} and {b} = "
|
problem = f"Common Factors of {a} and {b} = "
|
||||||
solution = arr
|
solution = arr
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
commonFactors = Generator("Common Factors", 40,
|
||||||
|
"Common Factors of {a} and {b} = ", "[c, d, ...]",
|
||||||
|
commonFactorsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def compareFractionsFunc(maxVal=10):
|
def compareFractionsFunc(maxVal=10):
|
||||||
@@ -24,3 +25,9 @@ def compareFractionsFunc(maxVal=10):
|
|||||||
|
|
||||||
problem = f"Which symbol represents the comparison between {a}/{b} and {c}/{d}?"
|
problem = f"Which symbol represents the comparison between {a}/{b} and {c}/{d}?"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
compareFractions = Generator(
|
||||||
|
"Compare Fractions", 44,
|
||||||
|
"Which symbol represents the comparison between a/b and c/d?", ">/</=",
|
||||||
|
compareFractionsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
@@ -21,3 +22,9 @@ def compoundInterestFunc(maxPrinciple=10000,
|
|||||||
t) + " compounded monthly is = "
|
t) + " compounded monthly is = "
|
||||||
solution = round(A, 2)
|
solution = round(A, 2)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def confidenceIntervalFunc():
|
def confidenceIntervalFunc():
|
||||||
@@ -29,3 +30,8 @@ def confidenceIntervalFunc():
|
|||||||
[x for x in lst], lst_per[j])
|
[x for x in lst], lst_per[j])
|
||||||
solution = '({}, {})'.format(mean + standard_error, mean - standard_error)
|
solution = '({}, {})'.format(mean + standard_error, mean - standard_error)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
confidenceInterval = Generator("Confidence interval For sample S", 54,
|
||||||
|
"With X% confidence", "is (A,B)",
|
||||||
|
confidenceIntervalFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def cubeRootFunc(minNo=1, maxNo=1000):
|
def cubeRootFunc(minNo=1, maxNo=1000):
|
||||||
@@ -8,3 +9,7 @@ def cubeRootFunc(minNo=1, maxNo=1000):
|
|||||||
problem = "cuberoot of " + str(b) + " upto 2 decimal places is:"
|
problem = "cuberoot of " + str(b) + " upto 2 decimal places is:"
|
||||||
solution = str(round(a, 2))
|
solution = str(round(a, 2))
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
CubeRoot = Generator("Cube Root", 47, "Cuberoot of a upto 2 decimal places is",
|
||||||
|
"b", cubeRootFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def dataSummaryFunc(number_values=15, minval=5, maxval=50):
|
def dataSummaryFunc(number_values=15, minval=5, maxval=50):
|
||||||
@@ -26,3 +27,7 @@ def dataSummaryFunc(number_values=15, minval=5, maxval=50):
|
|||||||
solution = "The Mean is {} , Standard Deviation is {}, Variance is {}".format(
|
solution = "The Mean is {} , Standard Deviation is {}, Variance is {}".format(
|
||||||
mean, var / number_values, (var / number_values)**0.5)
|
mean, var / number_values, (var / number_values)**0.5)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
dataSummary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c",
|
||||||
|
"Mean:a+b+c/3,Std,Var", dataSummaryFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def deciToHexaFunc(max_dec=1000):
|
def deciToHexaFunc(max_dec=1000):
|
||||||
@@ -8,3 +9,7 @@ def deciToHexaFunc(max_dec=1000):
|
|||||||
solution = str(b)
|
solution = str(b)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
decimalToHexadeci = Generator("Decimal to Hexadecimal", 79, "Binary of a=",
|
||||||
|
"b", deciToHexaFunc)
|
||||||
|
|||||||
12
mathgenerator/funcs/decimalToOctalFunc.py
Normal file
12
mathgenerator/funcs/decimalToOctalFunc.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from .__init__ import *
|
||||||
|
|
||||||
|
|
||||||
|
def decimalToOctalFunc(maxDecimal=4096):
|
||||||
|
x = random.randint(0, maxDecimal)
|
||||||
|
problem = "The decimal number " + str(x) + " in Octal is: "
|
||||||
|
solution = oct(x)
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
decimalToOctal = Generator("Converts decimal to octal", 84,
|
||||||
|
"What's the octal representation of 98?", "0o142", decimalToOctalFunc)
|
||||||
29
mathgenerator/funcs/decimalToRomanNumeralsFunc.py
Normal file
29
mathgenerator/funcs/decimalToRomanNumeralsFunc.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
from .__init__ import *
|
||||||
|
|
||||||
|
|
||||||
|
def decimalToRomanNumeralsFunc(maxDecimal=4000):
|
||||||
|
x = random.randint(0, maxDecimal)
|
||||||
|
problem = "The number " + str(x) + " in Roman Numerals is: "
|
||||||
|
roman_dict = {1: "I", 5: "V", 10: "X", 50: "L", 100: "C", 500: "D", 1000: "M"}
|
||||||
|
divisor = 1
|
||||||
|
while x >= divisor:
|
||||||
|
divisor *= 10
|
||||||
|
divisor /= 10
|
||||||
|
solution = ""
|
||||||
|
while x:
|
||||||
|
last_value = int(x / divisor)
|
||||||
|
if last_value <= 3:
|
||||||
|
solution += (roman_dict[divisor] * last_value)
|
||||||
|
elif last_value == 4:
|
||||||
|
solution += (roman_dict[divisor] * roman_dict[divisor * 5])
|
||||||
|
elif 5 <= last_value <= 8:
|
||||||
|
solution += (roman_dict[divisor * 5] + (roman_dict[divisor] * (last_value - 5)))
|
||||||
|
elif last_value == 9:
|
||||||
|
solution += (roman_dict[divisor] + roman_dict[divisor * 10])
|
||||||
|
x = math.floor(x % divisor)
|
||||||
|
divisor /= 10
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
decimalToRomanNumerals = Generator("Converts decimal to Roman Numerals",
|
||||||
|
85, "Convert 20 into Roman Numerals", "XX", decimalToRomanNumeralsFunc)
|
||||||
16
mathgenerator/funcs/degreeToRadFunc.py
Normal file
16
mathgenerator/funcs/degreeToRadFunc.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from .__init__ import *
|
||||||
|
from numpy import pi
|
||||||
|
|
||||||
|
|
||||||
|
def degreeToRadFunc(max_deg=360):
|
||||||
|
a = random.randint(0, max_deg)
|
||||||
|
b = (pi * a) / 180
|
||||||
|
b = round(b, 2)
|
||||||
|
|
||||||
|
problem = "Angle " + str(a) + " in radians is = "
|
||||||
|
solution = str(b)
|
||||||
|
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
degreeToRad = Generator("Degrees to Radians", 86, "Angle a in radians is = ", "b", degreeToRadFunc)
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def determinantToMatrix22(maxMatrixVal=100):
|
def determinantToMatrix22(maxMatrixVal=100):
|
||||||
@@ -11,3 +12,8 @@ def determinantToMatrix22(maxMatrixVal=100):
|
|||||||
problem = f"Det([[{a}, {b}], [{c}, {d}]]) = "
|
problem = f"Det([[{a}, {b}], [{c}, {d}]]) = "
|
||||||
solution = f" {determinant}"
|
solution = f" {determinant}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
intMatrix22determinant = Generator("Determinant to 2x2 Matrix", 77,
|
||||||
|
"Det([[a,b],[c,d]]) =", " a * d - b * c",
|
||||||
|
determinantToMatrix22)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
|
def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
|
||||||
@@ -12,3 +13,8 @@ def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
|
|||||||
solution = f"sqrt({distanceSq})"
|
solution = f"sqrt({distanceSq})"
|
||||||
problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})"
|
problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
distance2Point = Generator("Distance between 2 points", 24,
|
||||||
|
"Find the distance between (x1,y1) and (x2,y2)",
|
||||||
|
"sqrt(distanceSquared)", distanceTwoPointsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def divideFractionsFunc(maxVal=10):
|
def divideFractionsFunc(maxVal=10):
|
||||||
@@ -30,3 +31,7 @@ def divideFractionsFunc(maxVal=10):
|
|||||||
problem = f"({a}/{b})/({c}/{d})"
|
problem = f"({a}/{b})/({c}/{d})"
|
||||||
solution = x
|
solution = x
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y",
|
||||||
|
divideFractionsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def divisionFunc(maxRes=99, maxDivid=99):
|
def divisionFunc(maxRes=99, maxDivid=99):
|
||||||
@@ -9,3 +10,6 @@ def divisionFunc(maxRes=99, maxDivid=99):
|
|||||||
problem = str(a) + "/" + str(b) + "="
|
problem = str(a) + "/" + str(b) + "="
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
division = Generator("Division", 3, "a/b=", "c", divisionFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def divisionToIntFunc(maxA=25, maxB=25):
|
def divisionToIntFunc(maxA=25, maxB=25):
|
||||||
@@ -11,3 +12,6 @@ def divisionToIntFunc(maxA=25, maxB=25):
|
|||||||
problem = f"{divisor}/{dividend} = "
|
problem = f"{divisor}/{dividend} = "
|
||||||
solution = int(divisor / dividend)
|
solution = int(divisor / dividend)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
intDivision = Generator("Easy Division", 13, "a/b=", "c", divisionToIntFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def euclidianNormFunc(maxEltAmt=20):
|
def euclidianNormFunc(maxEltAmt=20):
|
||||||
@@ -6,3 +7,8 @@ def euclidianNormFunc(maxEltAmt=20):
|
|||||||
problem = f"Euclidian norm or L2 norm of the vector{vec} is:"
|
problem = f"Euclidian norm or L2 norm of the vector{vec} is:"
|
||||||
solution = math.sqrt(sum([i**2 for i in vec]))
|
solution = math.sqrt(sum([i**2 for i in vec]))
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
eucldianNorm = Generator("Euclidian norm or L2 norm of a vector", 69,
|
||||||
|
"Euclidian Norm of a vector V:[v1, v2, ......., vn]",
|
||||||
|
"sqrt(v1^2 + v2^2 ........ +vn^2)", euclidianNormFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def exponentiationFunc(maxBase=20, maxExpo=10):
|
def exponentiationFunc(maxBase=20, maxExpo=10):
|
||||||
@@ -8,3 +9,7 @@ def exponentiationFunc(maxBase=20, maxExpo=10):
|
|||||||
problem = f"{base}^{expo} ="
|
problem = f"{base}^{expo} ="
|
||||||
solution = str(base**expo)
|
solution = str(base**expo)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
exponentiation = Generator("Exponentiation", 53, "a^b = ", "c",
|
||||||
|
exponentiationFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def factorialFunc(maxInput=6):
|
def factorialFunc(maxInput=6):
|
||||||
@@ -13,3 +14,6 @@ def factorialFunc(maxInput=6):
|
|||||||
n -= 1
|
n -= 1
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
factorial = Generator("Factorial", 31, "a! = ", "b", factorialFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def factoringFunc(range_x1=10, range_x2=10):
|
def factoringFunc(range_x1=10, range_x2=10):
|
||||||
@@ -27,3 +28,7 @@ def factoringFunc(range_x1=10, range_x2=10):
|
|||||||
x2 = intParser(x2)
|
x2 = intParser(x2)
|
||||||
solution = f"(x{x1})(x{x2})"
|
solution = f"(x{x1})(x{x2})"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
factoring = Generator("Factoring Quadratic", 21, "x^2+(x1+x2)+x1*x2",
|
||||||
|
"(x-x1)(x-x2)", factoringFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def fibonacciSeriesFunc(minNo=1):
|
def fibonacciSeriesFunc(minNo=1):
|
||||||
@@ -19,3 +20,8 @@ def fibonacciSeriesFunc(minNo=1):
|
|||||||
problem = "The Fibonacci Series of the first " + str(n) + " numbers is ?"
|
problem = "The Fibonacci Series of the first " + str(n) + " numbers is ?"
|
||||||
solution = fibList
|
solution = fibList
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
fibonacciSeries = Generator(
|
||||||
|
"Fibonacci Series", 56, "fibonacci series of first a numbers",
|
||||||
|
"prints the fibonacci series starting from 0 to a", fibonacciSeriesFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def fourthAngleOfQuadriFunc(maxAngle=180):
|
def fourthAngleOfQuadriFunc(maxAngle=180):
|
||||||
@@ -12,3 +13,9 @@ def fourthAngleOfQuadriFunc(maxAngle=180):
|
|||||||
problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} ="
|
problem = f"Fourth angle of quadrilateral with angles {angle1} , {angle2}, {angle3} ="
|
||||||
solution = angle4
|
solution = angle4
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
fourthAngleOfQuadrilateral = Generator(
|
||||||
|
"Fourth Angle of Quadrilateral", 49,
|
||||||
|
"Fourth angle of Quadrilateral with angles a,b,c =", "angle4",
|
||||||
|
fourthAngleOfQuadriFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def gcdFunc(maxVal=20):
|
def gcdFunc(maxVal=20):
|
||||||
@@ -10,3 +11,7 @@ def gcdFunc(maxVal=20):
|
|||||||
problem = f"GCD of {a} and {b} = "
|
problem = f"GCD of {a} and {b} = "
|
||||||
solution = str(x)
|
solution = str(x)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
gcd = Generator("GCD (Greatest Common Denominator)", 10, "GCD of a and b = ",
|
||||||
|
"c", gcdFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def geomProgrFunc(number_values=6,
|
def geomProgrFunc(number_values=6,
|
||||||
@@ -21,3 +22,9 @@ def geomProgrFunc(number_values=6,
|
|||||||
solution = "The value of a is {}, common ratio is {} , {}th term is {} , sum upto {}th term is {}".format(
|
solution = "The value of a is {}, common ratio is {} , {}th term is {} , sum upto {}th term is {}".format(
|
||||||
a, r, n_term, value_nth_term, sum_term, sum_till_nth_term)
|
a, r, n_term, value_nth_term, sum_term, sum_till_nth_term)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
geometricprogression = Generator(
|
||||||
|
"Geometric Progression", 66,
|
||||||
|
"Initial value,Common Ratio,nth Term,Sum till nth term =",
|
||||||
|
"a,r,ar^n-1,sum(ar^n-1", geomProgrFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def geometricMeanFunc(maxValue=100, maxNum=4):
|
def geometricMeanFunc(maxValue=100, maxNum=4):
|
||||||
@@ -25,3 +26,8 @@ def geometricMeanFunc(maxValue=100, maxNum=4):
|
|||||||
problem = f"Geometric mean of {num} numbers {a} , {b} , {c} , {d} = "
|
problem = f"Geometric mean of {num} numbers {a} , {b} , {c} , {d} = "
|
||||||
solution = f"({a}*{b}*{c}*{d})^(1/{num}) = {ans}"
|
solution = f"({a}*{b}*{c}*{d})^(1/{num}) = {ans}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
geometricMean = Generator("Geometric Mean of N Numbers", 67,
|
||||||
|
"Geometric mean of n numbers A1 , A2 , ... , An = ",
|
||||||
|
"(A1*A2*...An)^(1/n) = ans", geometricMeanFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def harmonicMeanFunc(maxValue=100, maxNum=4):
|
def harmonicMeanFunc(maxValue=100, maxNum=4):
|
||||||
@@ -26,3 +27,9 @@ def harmonicMeanFunc(maxValue=100, maxNum=4):
|
|||||||
problem = f"Harmonic mean of {num} numbers {a} , {b} , {c} , {d} = "
|
problem = f"Harmonic mean of {num} numbers {a} , {b} , {c} , {d} = "
|
||||||
solution = f" {num}/((1/{a}) + (1/{b}) + (1/{c}) + (1/{d})) = {ans}"
|
solution = f" {num}/((1/{a}) + (1/{b}) + (1/{c}) + (1/{d})) = {ans}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
harmonicMean = Generator("Harmonic Mean of N Numbers", 68,
|
||||||
|
"Harmonic mean of n numbers A1 , A2 , ... , An = ",
|
||||||
|
" n/((1/A1) + (1/A2) + ... + (1/An)) = ans",
|
||||||
|
harmonicMeanFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def hcfFunc(maxVal=20):
|
def hcfFunc(maxVal=20):
|
||||||
@@ -10,3 +11,7 @@ def hcfFunc(maxVal=20):
|
|||||||
problem = f"HCF of {a} and {b} = "
|
problem = f"HCF of {a} and {b} = "
|
||||||
solution = str(x)
|
solution = str(x)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
hcf = Generator("HCF (Highest Common Factor)", 51, "HCF of a and b = ", "c",
|
||||||
|
hcfFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def intersectionOfTwoLinesFunc(minM=-10,
|
def intersectionOfTwoLinesFunc(minM=-10,
|
||||||
@@ -64,3 +65,9 @@ def intersectionOfTwoLinesFunc(minM=-10,
|
|||||||
solution = f"({fractionToString(intersection_x)}, {fractionToString(intersection_y)})"
|
solution = f"({fractionToString(intersection_x)}, {fractionToString(intersection_y)})"
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
intersectionOfTwoLines = Generator(
|
||||||
|
"Intersection of Two Lines", 41,
|
||||||
|
"Find the point of intersection of the two lines: y = m1*x + b1 and y = m2*x + b2",
|
||||||
|
"(x, y)", intersectionOfTwoLinesFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def isTriangleValidFunc(maxSideLength=50):
|
def isTriangleValidFunc(maxSideLength=50):
|
||||||
@@ -18,3 +19,8 @@ def isTriangleValidFunc(maxSideLength=50):
|
|||||||
return problem, solution
|
return problem, solution
|
||||||
solution = "No"
|
solution = "No"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
doesTriangleExist = Generator("Triangle exists check", 19,
|
||||||
|
"Does triangle with sides a, b and c exist?",
|
||||||
|
"Yes/No", isTriangleValidFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def lcmFunc(maxVal=20):
|
def lcmFunc(maxVal=20):
|
||||||
@@ -15,3 +16,7 @@ def lcmFunc(maxVal=20):
|
|||||||
solution = str(d)
|
solution = str(d)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
lcm = Generator("LCM (Least Common Multiple)", 9, "LCM of a and b = ", "c",
|
||||||
|
lcmFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def linearEquationsFunc(n=2, varRange=20, coeffRange=20):
|
def linearEquationsFunc(n=2, varRange=20, coeffRange=20):
|
||||||
@@ -27,3 +28,7 @@ def linearEquationsFunc(n=2, varRange=20, coeffRange=20):
|
|||||||
|
|
||||||
problem = "\n".join(problem)
|
problem = "\n".join(problem)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12",
|
||||||
|
"x=-20 & y=12", linearEquationsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def logFunc(maxBase=3, maxVal=8):
|
def logFunc(maxBase=3, maxVal=8):
|
||||||
@@ -10,3 +11,6 @@ def logFunc(maxBase=3, maxVal=8):
|
|||||||
solution = str(a)
|
solution = str(a)
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
log = Generator("Logarithm", 12, "log2(8)", "3", logFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
import sympy
|
import sympy
|
||||||
|
|
||||||
|
|
||||||
@@ -76,3 +77,7 @@ def matrixInversion(SquareMatrixDimension=3,
|
|||||||
problem = 'Inverse of Matrix ' + str(Mat) + ' is:'
|
problem = 'Inverse of Matrix ' + str(Mat) + ' is:'
|
||||||
solution = str(sympy.Matrix.inv(Mat))
|
solution = str(sympy.Matrix.inv(Mat))
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
invertmatrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is",
|
||||||
|
"A^(-1)", matrixInversion)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def matrixMultiplicationFunc(maxVal=100, max_dim=10):
|
def matrixMultiplicationFunc(maxVal=100, max_dim=10):
|
||||||
@@ -51,3 +52,8 @@ def matrixMultiplicationFuncHelper(inp):
|
|||||||
string += "]]"
|
string += "]]"
|
||||||
|
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
|
matrixMultiplication = Generator("Multiplication of two matrices", 46,
|
||||||
|
"Multiply two matrices A and B", "C",
|
||||||
|
matrixMultiplicationFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def meanMedianFunc(maxlen=10):
|
def meanMedianFunc(maxlen=10):
|
||||||
@@ -12,3 +13,8 @@ def meanMedianFunc(maxlen=10):
|
|||||||
median = (randomlist[4] + randomlist[5]) / 2
|
median = (randomlist[4] + randomlist[5]) / 2
|
||||||
solution = f"Arithmetic mean of the series is {mean} and Arithmetic median of this series is {median}"
|
solution = f"Arithmetic mean of the series is {mean} and Arithmetic median of this series is {median}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
meanMedian = Generator("Mean and Median", 76,
|
||||||
|
"Mean and median of given set of numbers",
|
||||||
|
"Mean, Median", meanMedianFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def moduloFunc(maxRes=99, maxModulo=99):
|
def moduloFunc(maxRes=99, maxModulo=99):
|
||||||
@@ -9,3 +10,6 @@ def moduloFunc(maxRes=99, maxModulo=99):
|
|||||||
problem = str(a) + "%" + str(b) + "="
|
problem = str(a) + "%" + str(b) + "="
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
moduloDivision = Generator("Modulo Division", 5, "a%b=", "c", moduloFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def multiplicationFunc(maxRes=99, maxMulti=99):
|
def multiplicationFunc(maxRes=99, maxMulti=99):
|
||||||
@@ -9,3 +10,7 @@ def multiplicationFunc(maxRes=99, maxMulti=99):
|
|||||||
problem = str(a) + "*" + str(b) + "="
|
problem = str(a) + "*" + str(b) + "="
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
multiplication = Generator("Multiplication", 2, "a*b=", "c",
|
||||||
|
multiplicationFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def multiplyComplexNumbersFunc(minRealImaginaryNum=-20,
|
def multiplyComplexNumbersFunc(minRealImaginaryNum=-20,
|
||||||
@@ -10,3 +11,8 @@ def multiplyComplexNumbersFunc(minRealImaginaryNum=-20,
|
|||||||
problem = f"{num1} * {num2} = "
|
problem = f"{num1} * {num2} = "
|
||||||
solution = num1 * num2
|
solution = num1 * num2
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
complexNumMultiply = Generator("Multiplication of 2 complex numbers", 65,
|
||||||
|
"(x + j) (y + j) = ", "xy + xj + yj -1",
|
||||||
|
multiplyComplexNumbersFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def multiplyFractionsFunc(maxVal=10):
|
def multiplyFractionsFunc(maxVal=10):
|
||||||
@@ -30,3 +31,8 @@ def multiplyFractionsFunc(maxVal=10):
|
|||||||
problem = f"({a}/{b})*({c}/{d})"
|
problem = f"({a}/{b})*({c}/{d})"
|
||||||
solution = x
|
solution = x
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
fractionMultiplication = Generator("Fraction Multiplication", 28,
|
||||||
|
"(a/b)*(c/d)=", "x/y",
|
||||||
|
multiplyFractionsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100):
|
def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100):
|
||||||
@@ -11,3 +12,9 @@ def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100):
|
|||||||
problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = "
|
problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = "
|
||||||
solution = f"[[{a*constant},{b*constant}],[{c*constant},{d*constant}]]"
|
solution = f"[[{a*constant},{b*constant}],[{c*constant},{d*constant}]]"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
intMatrix22Multiplication = Generator("Integer Multiplication with 2x2 Matrix",
|
||||||
|
17, "k * [[a,b],[c,d]]=",
|
||||||
|
"[[k*a,k*b],[k*c,k*d]]",
|
||||||
|
multiplyIntToMatrix22)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def nthFibonacciNumberFunc(maxN=100):
|
def nthFibonacciNumberFunc(maxN=100):
|
||||||
@@ -8,3 +9,8 @@ def nthFibonacciNumberFunc(maxN=100):
|
|||||||
ans = round((math.pow(golden_ratio, n) - math.pow(-golden_ratio, -n)) / (math.sqrt(5)))
|
ans = round((math.pow(golden_ratio, n) - math.pow(-golden_ratio, -n)) / (math.sqrt(5)))
|
||||||
solution = f"{ans}"
|
solution = f"{ans}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
nthFibonacciNumberGen = Generator("nth Fibonacci number", 62,
|
||||||
|
"What is the nth Fibonacci number", "Fn",
|
||||||
|
nthFibonacciNumberFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def percentageFunc(maxValue=99, maxpercentage=99):
|
def percentageFunc(maxValue=99, maxpercentage=99):
|
||||||
@@ -9,3 +10,7 @@ def percentageFunc(maxValue=99, maxpercentage=99):
|
|||||||
formatted_float = "{:.2f}".format(percentage)
|
formatted_float = "{:.2f}".format(percentage)
|
||||||
solution = f"Required percentage = {formatted_float}%"
|
solution = f"Required percentage = {formatted_float}%"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
percentage = Generator("Percentage of a number", 80, "What is a% of b?",
|
||||||
|
"percentage", percentageFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def permutationFunc(maxlength=20):
|
def permutationFunc(maxlength=20):
|
||||||
@@ -9,3 +10,9 @@ def permutationFunc(maxlength=20):
|
|||||||
problem = "Number of Permutations from {} objects picked {} at a time = ".format(
|
problem = "Number of Permutations from {} objects picked {} at a time = ".format(
|
||||||
a, b)
|
a, b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
permutations = Generator(
|
||||||
|
"Permutations", 42,
|
||||||
|
"Total permutations of 4 objects at a time from 10 objects is", "5040",
|
||||||
|
permutationFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
||||||
@@ -16,3 +17,8 @@ def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
|||||||
problem += str(coefficient) + "x^" + str(exponent)
|
problem += str(coefficient) + "x^" + str(exponent)
|
||||||
solution += str(coefficient * exponent) + "x^" + str(exponent - 1)
|
solution += str(coefficient * exponent) + "x^" + str(exponent - 1)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
powerRuleDifferentiation = Generator("Power Rule Differentiation", 7, "nx^m=",
|
||||||
|
"(n*m)x^(m-1)",
|
||||||
|
powerRuleDifferentiationFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def powerRuleIntegrationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
def powerRuleIntegrationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
||||||
@@ -19,3 +20,7 @@ def powerRuleIntegrationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
|||||||
|
|
||||||
solution += " + c"
|
solution += " + c"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=",
|
||||||
|
"(n/m)x^(m+1)", powerRuleIntegrationFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def primeFactorsFunc(minVal=1, maxVal=200):
|
def primeFactorsFunc(minVal=1, maxVal=200):
|
||||||
@@ -20,3 +21,7 @@ def primeFactorsFunc(minVal=1, maxVal=200):
|
|||||||
problem = f"Find prime factors of {a}"
|
problem = f"Find prime factors of {a}"
|
||||||
solution = f"{factors}"
|
solution = f"{factors}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =",
|
||||||
|
"[b, c, d, ...]", primeFactorsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def profitLossPercentFunc(maxCP=1000, maxSP=1000):
|
def profitLossPercentFunc(maxCP=1000, maxSP=1000):
|
||||||
@@ -14,3 +15,9 @@ def profitLossPercentFunc(maxCP=1000, maxSP=1000):
|
|||||||
solution = percent
|
solution = percent
|
||||||
|
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
profitLossPercent = Generator(
|
||||||
|
"Profit or Loss Percent", 63,
|
||||||
|
"Profit/ Loss percent when CP = cp and SP = sp is: ", "percent",
|
||||||
|
profitLossPercentFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def pythagoreanTheoremFunc(maxLength=20):
|
def pythagoreanTheoremFunc(maxLength=20):
|
||||||
@@ -9,3 +10,9 @@ def pythagoreanTheoremFunc(maxLength=20):
|
|||||||
problem = f"The hypotenuse of a right triangle given the other two lengths {a} and {b} = "
|
problem = f"The hypotenuse of a right triangle given the other two lengths {a} and {b} = "
|
||||||
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
|
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
pythagoreanTheorem = Generator(
|
||||||
|
"Pythagorean Theorem", 25,
|
||||||
|
"The hypotenuse of a right triangle given the other two lengths a and b = ",
|
||||||
|
"hypotenuse", pythagoreanTheoremFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def quadraticEquation(maxVal=100):
|
def quadraticEquation(maxVal=100):
|
||||||
@@ -13,3 +14,9 @@ def quadraticEquation(maxVal=100):
|
|||||||
[round((-b + D) / (2 * a), 2),
|
[round((-b + D) / (2 * a), 2),
|
||||||
round((-b - D) / (2 * a), 2)])
|
round((-b - D) / (2 * a), 2)])
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
quadraticEquationSolve = Generator(
|
||||||
|
"Quadratic Equation", 50,
|
||||||
|
"Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2",
|
||||||
|
quadraticEquation)
|
||||||
|
|||||||
16
mathgenerator/funcs/radianToDegFunc.py
Normal file
16
mathgenerator/funcs/radianToDegFunc.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from .__init__ import *
|
||||||
|
from numpy import pi
|
||||||
|
|
||||||
|
|
||||||
|
def radianToDegFunc(max_rad=pi):
|
||||||
|
a = random.randint(0, max_rad)
|
||||||
|
b = (180 * a) / pi
|
||||||
|
b = round(b, 2)
|
||||||
|
|
||||||
|
problem = "Angle " + str(a) + " in degrees is = "
|
||||||
|
solution = str(b)
|
||||||
|
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
radianToDeg = Generator("Radians to Degrees", 87, "Angle a in degrees is = ", "b", radianToDegFunc)
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def regularPolygonAngleFunc(minVal=3, maxVal=20):
|
def regularPolygonAngleFunc(minVal=3, maxVal=20):
|
||||||
@@ -8,3 +9,9 @@ def regularPolygonAngleFunc(minVal=3, maxVal=20):
|
|||||||
exteriorAngle = round((360 / sideNum), 2)
|
exteriorAngle = round((360 / sideNum), 2)
|
||||||
solution = 180 - exteriorAngle
|
solution = 180 - exteriorAngle
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
angleRegularPolygon = Generator(
|
||||||
|
"Angle of a Regular Polygon", 29,
|
||||||
|
"Find the angle of a regular polygon with 6 sides", "120",
|
||||||
|
regularPolygonAngleFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def sectorAreaFunc(maxRadius=49, maxAngle=359):
|
def sectorAreaFunc(maxRadius=49, maxAngle=359):
|
||||||
@@ -9,3 +10,8 @@ def sectorAreaFunc(maxRadius=49, maxAngle=359):
|
|||||||
formatted_float = "{:.5f}".format(secArea)
|
formatted_float = "{:.5f}".format(secArea)
|
||||||
solution = f"Area of sector = {formatted_float}"
|
solution = f"Area of sector = {formatted_float}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
sectorArea = Generator("Area of a Sector", 75,
|
||||||
|
"Area of a sector with radius, r and angle, a ", "Area",
|
||||||
|
sectorAreaFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def simpleInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
|
def simpleInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
|
||||||
@@ -13,3 +14,9 @@ def simpleInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
|
|||||||
c) + " years is = "
|
c) + " years is = "
|
||||||
solution = round(d, 2)
|
solution = round(d, 2)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
simpleInterest = Generator(
|
||||||
|
"Simple Interest", 45,
|
||||||
|
"Simple interest for a principle amount of a dollars, b% rate of interest and for a time period of c years is = ",
|
||||||
|
"d dollars", simpleInterestFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def squareFunc(maxSquareNum=20):
|
def squareFunc(maxSquareNum=20):
|
||||||
@@ -8,3 +9,6 @@ def squareFunc(maxSquareNum=20):
|
|||||||
problem = str(a) + "^2" + "="
|
problem = str(a) + "^2" + "="
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
square = Generator("Square", 8, "a^2", "b", squareFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def squareRootFunc(minNo=1, maxNo=12):
|
def squareRootFunc(minNo=1, maxNo=12):
|
||||||
@@ -8,3 +9,6 @@ def squareRootFunc(minNo=1, maxNo=12):
|
|||||||
problem = "sqrt(" + str(a) + ")="
|
problem = "sqrt(" + str(a) + ")="
|
||||||
solution = str(b)
|
solution = str(b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
squareRoot = Generator("Square Root", 6, "sqrt(a)=", "b", squareRootFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def subtractionFunc(maxMinuend=99, maxDiff=99):
|
def subtractionFunc(maxMinuend=99, maxDiff=99):
|
||||||
@@ -9,3 +10,6 @@ def subtractionFunc(maxMinuend=99, maxDiff=99):
|
|||||||
problem = str(a) + "-" + str(b) + "="
|
problem = str(a) + "-" + str(b) + "="
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
subtraction = Generator("Subtraction", 1, "a-b=", "c", subtractionFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def sumOfAnglesOfPolygonFunc(maxSides=12):
|
def sumOfAnglesOfPolygonFunc(maxSides=12):
|
||||||
@@ -8,3 +9,8 @@ def sumOfAnglesOfPolygonFunc(maxSides=12):
|
|||||||
problem = f"Sum of angles of polygon with {side} sides = "
|
problem = f"Sum of angles of polygon with {side} sides = "
|
||||||
solution = sum
|
solution = sum
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58,
|
||||||
|
"Sum of angles of polygon with n sides = ",
|
||||||
|
"sum", sumOfAnglesOfPolygonFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def surdsComparisonFunc(maxValue=100, maxRoot=10):
|
def surdsComparisonFunc(maxValue=100, maxRoot=10):
|
||||||
@@ -15,3 +16,8 @@ def surdsComparisonFunc(maxValue=100, maxRoot=10):
|
|||||||
elif first < second:
|
elif first < second:
|
||||||
solution = "<"
|
solution = "<"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
surdsComparison = Generator("Comparing surds", 55,
|
||||||
|
"Fill in the blanks a^(1/b) _ c^(1/d)", "</>/=",
|
||||||
|
surdsComparisonFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):
|
def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):
|
||||||
@@ -11,3 +12,9 @@ def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):
|
|||||||
|
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
surfaceAreaConeGen = Generator(
|
||||||
|
"Surface Area of cone", 38,
|
||||||
|
"Surface area of cone with height = a units and radius = b units is",
|
||||||
|
"c units^2", surfaceAreaCone)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def surfaceAreaCube(maxSide=20, unit='m'):
|
def surfaceAreaCube(maxSide=20, unit='m'):
|
||||||
@@ -7,3 +8,8 @@ def surfaceAreaCube(maxSide=20, unit='m'):
|
|||||||
ans = 6 * a * a
|
ans = 6 * a * a
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
surfaceAreaCubeGen = Generator("Surface Area of Cube", 32,
|
||||||
|
"Surface area of cube with side a units is",
|
||||||
|
"b units^2", surfaceAreaCube)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def surfaceAreaCuboid(maxSide=20, unit='m'):
|
def surfaceAreaCuboid(maxSide=20, unit='m'):
|
||||||
@@ -10,3 +11,9 @@ def surfaceAreaCuboid(maxSide=20, unit='m'):
|
|||||||
ans = 2 * (a * b + b * c + c * a)
|
ans = 2 * (a * b + b * c + c * a)
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
surfaceAreaCuboidGen = Generator(
|
||||||
|
"Surface Area of Cuboid", 33,
|
||||||
|
"Surface area of cuboid with sides = a units, b units, c units is",
|
||||||
|
"d units^2", surfaceAreaCuboid)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
||||||
@@ -9,3 +10,9 @@ def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
|||||||
ans = int(2 * math.pi * a * b + 2 * math.pi * b * b)
|
ans = int(2 * math.pi * a * b + 2 * math.pi * b * b)
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
surfaceAreaCylinderGen = Generator(
|
||||||
|
"Surface Area of Cylinder", 34,
|
||||||
|
"Surface area of cylinder with height = a units and radius = b units is",
|
||||||
|
"c units^2", surfaceAreaCylinder)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def surfaceAreaSphere(maxSide=20, unit='m'):
|
def surfaceAreaSphere(maxSide=20, unit='m'):
|
||||||
@@ -8,3 +9,9 @@ def surfaceAreaSphere(maxSide=20, unit='m'):
|
|||||||
ans = 4 * math.pi * r * r
|
ans = 4 * math.pi * r * r
|
||||||
solution = f"{ans} {unit}^2"
|
solution = f"{ans} {unit}^2"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
surfaceAreaSphereGen = Generator(
|
||||||
|
"Surface Area of Sphere", 60,
|
||||||
|
"Surface area of sphere with radius = a units is", "d units^2",
|
||||||
|
surfaceAreaSphere)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def systemOfEquationsFunc(range_x=10, range_y=10, coeff_mult_range=10):
|
def systemOfEquationsFunc(range_x=10, range_y=10, coeff_mult_range=10):
|
||||||
@@ -45,3 +46,8 @@ def systemOfEquationsFunc(range_x=10, range_y=10, coeff_mult_range=10):
|
|||||||
solution = f"x = {x}, y = {y}"
|
solution = f"x = {x}, y = {y}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
# Add random (non-zero) multiple of equations to each other
|
# Add random (non-zero) multiple of equations to each other
|
||||||
|
|
||||||
|
|
||||||
|
systemOfEquations = Generator("Solve a System of Equations in R^2", 23,
|
||||||
|
"2x + 5y = 13, -3x - 3y = -6", "x = -1, y = 3",
|
||||||
|
systemOfEquationsFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def thirdAngleOfTriangleFunc(maxAngle=89):
|
def thirdAngleOfTriangleFunc(maxAngle=89):
|
||||||
@@ -9,3 +10,8 @@ def thirdAngleOfTriangleFunc(maxAngle=89):
|
|||||||
problem = f"Third angle of triangle with angles {angle1} and {angle2} = "
|
problem = f"Third angle of triangle with angles {angle1} and {angle2} = "
|
||||||
solution = angle3
|
solution = angle3
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
thirdAngleOfTriangle = Generator("Third Angle of Triangle", 22,
|
||||||
|
"Third Angle of the triangle = ", "angle3",
|
||||||
|
thirdAngleOfTriangleFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def vectorCrossFunc(minVal=-20, maxVal=20):
|
def vectorCrossFunc(minVal=-20, maxVal=20):
|
||||||
@@ -12,3 +13,7 @@ def vectorCrossFunc(minVal=-20, maxVal=20):
|
|||||||
problem = str(a) + " X " + str(b) + " = "
|
problem = str(a) + " X " + str(b) + " = "
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
vectorCross = Generator("Cross Product of 2 Vectors", 43, "a X b = ", "c",
|
||||||
|
vectorCrossFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def vectorDotFunc(minVal=-20, maxVal=20):
|
def vectorDotFunc(minVal=-20, maxVal=20):
|
||||||
@@ -9,3 +10,7 @@ def vectorDotFunc(minVal=-20, maxVal=20):
|
|||||||
problem = str(a) + " . " + str(b) + " = "
|
problem = str(a) + " . " + str(b) + " = "
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
vectorDot = Generator("Dot Product of 2 Vectors", 72, "a . b = ", "c",
|
||||||
|
vectorDotFunc)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def volumeCone(maxRadius=20, maxHeight=50, unit='m'):
|
def volumeCone(maxRadius=20, maxHeight=50, unit='m'):
|
||||||
@@ -9,3 +10,9 @@ def volumeCone(maxRadius=20, maxHeight=50, unit='m'):
|
|||||||
ans = int(math.pi * b * b * a * (1 / 3))
|
ans = int(math.pi * b * b * a * (1 / 3))
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
volumeConeGen = Generator(
|
||||||
|
"Volume of cone", 39,
|
||||||
|
"Volume of cone with height = a units and radius = b units is",
|
||||||
|
"c units^3", volumeCone)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def volumeCube(maxSide=20, unit='m'):
|
def volumeCube(maxSide=20, unit='m'):
|
||||||
@@ -8,3 +9,8 @@ def volumeCube(maxSide=20, unit='m'):
|
|||||||
ans = a * a * a
|
ans = a * a * a
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
volumeCubeGen = Generator("Volum of Cube", 35,
|
||||||
|
"Volume of cube with side a units is", "b units^3",
|
||||||
|
volumeCube)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def volumeCuboid(maxSide=20, unit='m'):
|
def volumeCuboid(maxSide=20, unit='m'):
|
||||||
@@ -10,3 +11,9 @@ def volumeCuboid(maxSide=20, unit='m'):
|
|||||||
ans = a * b * c
|
ans = a * b * c
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
volumeCuboidGen = Generator(
|
||||||
|
"Volume of Cuboid", 36,
|
||||||
|
"Volume of cuboid with sides = a units, b units, c units is", "d units^3",
|
||||||
|
volumeCuboid)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def volumeCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
def volumeCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
||||||
@@ -9,3 +10,9 @@ def volumeCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
|||||||
ans = int(math.pi * b * b * a)
|
ans = int(math.pi * b * b * a)
|
||||||
solution = f"{ans} {unit}^3"
|
solution = f"{ans} {unit}^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
volumeCylinderGen = Generator(
|
||||||
|
"Volume of cylinder", 37,
|
||||||
|
"Volume of cylinder with height = a units and radius = b units is",
|
||||||
|
"c units^3", volumeCylinder)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from .__init__ import *
|
from .__init__ import *
|
||||||
|
from ..__init__ import Generator
|
||||||
|
|
||||||
|
|
||||||
def volumeSphereFunc(maxRadius=100):
|
def volumeSphereFunc(maxRadius=100):
|
||||||
@@ -8,3 +9,8 @@ def volumeSphereFunc(maxRadius=100):
|
|||||||
ans = (4 * math.pi / 3) * r * r * r
|
ans = (4 * math.pi / 3) * r * r * r
|
||||||
solution = f"{ans} m^3"
|
solution = f"{ans} m^3"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
volumeSphere = Generator("Volume of Sphere", 61,
|
||||||
|
"Volume of sphere with radius r m = ",
|
||||||
|
"(4*pi/3)*r*r*r", volumeSphereFunc)
|
||||||
|
|||||||
@@ -33,12 +33,9 @@ def genById(id):
|
|||||||
return (generator())
|
return (generator())
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# def getGenList():
|
|
||||||
# return(genList)
|
|
||||||
|
|
||||||
# Format is:
|
# Format is:
|
||||||
# <title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>)
|
# <title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>)
|
||||||
|
|
||||||
# Funcs_start - DO NOT REMOVE!
|
# Funcs_start - DO NOT REMOVE!
|
||||||
# addition = Generator("Addition", 0, "a+b=", "c", additionFunc)
|
# addition = Generator("Addition", 0, "a+b=", "c", additionFunc)
|
||||||
subtraction = Generator("Subtraction", 1, "a-b=", "c", subtractionFunc)
|
subtraction = Generator("Subtraction", 1, "a-b=", "c", subtractionFunc)
|
||||||
|
|||||||
Reference in New Issue
Block a user