| ")
@@ -19,8 +18,6 @@ with open('mathgenerator/mathgen.py', 'r') as f:
lines = f.readlines()
allRows = []
-# get the first line of the functions in mathgen.py
-line = lines.index('# Funcs_start - DO NOT REMOVE!\n') + 1
for item in wList:
myGen = item[2]
# NOTE: renamed 'sol' to 'solu' to make it look nicer
@@ -29,20 +26,16 @@ for item in wList:
solu = str(solu).rstrip("\n")
# edge case for matrixMultiplication
if item[0] == 46:
- prob, solu = myGen(10, 4)
+ prob, solu = myGen(maxVal=10, max_dim=4)
prob = str(prob).rstrip("\n")
solu = str(solu).rstrip("\n")
prob = array2markdown_table(prob)
solu = array2markdown_table(solu)
- instName = lines[line]
# NOTE: renamed 'def_name' to 'func_name' because it suits it more
- func_name = instName[:instName.find('=')].strip()
+ func_name = item[3]
row = [myGen.id, myGen.title, prob, solu, func_name]
- print('added', item[1],'-', func_name, 'to the README.md')
- line += 1
- if line > len(lines):
- break
+ print('added', item[1], '-', func_name, 'to the README.md')
allRows.append(row)
with open('README.md', "r") as g:
diff --git a/mathgenerator/__init__.py b/mathgenerator/__init__.py
index 956697a..090e18a 100644
--- a/mathgenerator/__init__.py
+++ b/mathgenerator/__init__.py
@@ -1,3 +1,5 @@
+import sys
+import traceback
genList = []
@@ -8,15 +10,20 @@ class Generator:
self.generalProb = generalProb
self.generalSol = generalSol
self.func = func
- genList.append([id, title, self])
+
+ (filename, line_number, function_name, text) = traceback.extract_stack()[-2]
+ funcname = filename[filename.rfind('/'):].strip()
+ funcname = funcname[1:-3]
+ # print(funcname)
+ genList.append([id, title, self, funcname])
def __str__(self):
return str(
self.id
) + " " + self.title + " " + self.generalProb + " " + self.generalSol
- def __call__(self, **kwargs):
- return self.func(**kwargs)
+ def __call__(self, *args, **kwargs):
+ return self.func(*args, **kwargs)
def getGenList():
diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py
index 12bf15e..221b641 100644
--- a/mathgenerator/funcs/__init__.py
+++ b/mathgenerator/funcs/__init__.py
@@ -2,91 +2,98 @@ import random
import math
import fractions
+from ..__init__ import *
+
from .addition import *
-from .subtractionFunc import *
-from .multiplicationFunc import *
-from .divisionFunc import *
-from .binaryComplement1sFunc import *
-from .moduloFunc import *
-from .squareRootFunc import *
-from .powerRuleDifferentiationFunc import *
-from .squareFunc import *
-from .lcmFunc import *
-from .gcdFunc import *
-from .basicAlgebraFunc import *
-from .logFunc import *
-from .divisionToIntFunc import *
-from .DecimalToBinaryFunc import *
-from .BinaryToDecimalFunc import *
-from .divideFractionsFunc import *
-from .multiplyIntToMatrix22 import *
-from .areaOfTriangleFunc import *
-from .isTriangleValidFunc import *
-from .MidPointOfTwoPointFunc import *
-from .factoringFunc import *
-from .thirdAngleOfTriangleFunc import *
-from .systemOfEquationsFunc import *
-from .distanceTwoPointsFunc import *
-from .pythagoreanTheoremFunc import *
-from .linearEquationsFunc import *
-from .primeFactorsFunc import *
-from .multiplyFractionsFunc import *
-from .regularPolygonAngleFunc import *
-from .combinationsFunc import *
-from .factorialFunc import *
-from .surfaceAreaCube import *
-from .surfaceAreaCuboid import *
-from .surfaceAreaCylinder import *
-from .volumeCube import *
-from .volumeCuboid import *
-from .volumeCylinder import *
-from .surfaceAreaCone import *
-from .volumeCone import *
-from .commonFactorsFunc import *
-from .intersectionOfTwoLinesFunc import *
-from .permutationFunc import *
-from .vectorCrossFunc import *
-from .compareFractionsFunc import *
-from .simpleInterestFunc import *
-from .matrixMultiplicationFunc import *
-from .cubeRootFunc import *
-from .powerRuleIntegrationFunc import *
-from .fourthAngleOfQuadriFunc import *
-from .quadraticEquation import *
-from .hcfFunc import *
-from .DiceSumProbFunc import *
-from .exponentiationFunc import *
-from .confidenceIntervalFunc import *
-from .surdsComparisonFunc import *
-from .fibonacciSeriesFunc import *
-from .basicTrigonometryFunc import *
-from .sumOfAnglesOfPolygonFunc import *
-from .dataSummaryFunc import *
-from .surfaceAreaSphere import *
-from .volumeSphereFunc import *
-from .nthFibonacciNumberFunc import *
-from .profitLossPercentFunc import *
-from .binaryToHexFunc import *
-from .multiplyComplexNumbersFunc import *
-from .geomProgrFunc import *
-from .geometricMeanFunc import *
-from .harmonicMeanFunc import *
-from .euclidianNormFunc import *
-from .angleBtwVectorsFunc import *
-from .absoluteDifferenceFunc import *
-from .vectorDotFunc import *
-from .binary2sComplement import *
-from .matrixInversion import *
-from .sectorAreaFunc import *
-from .meanMedianFunc import *
-from .determinantToMatrix22 import *
-from .compoundInterestFunc import *
-from .deciToHexaFunc import *
-from .percentageFunc import *
-from .celsiustofahrenheit import *
-from .arithmeticProgressionTermFunc import *
-from .arithmeticProgressionSumFunc import *
-from .decimalToOctalFunc import *
-from .decimalToRomanNumeralsFunc import *
-from .degreeToRadFunc import *
-from .radianToDegFunc import *
+from .subtraction import *
+from .multiplication import *
+from .division import *
+from .binary_complement_1s import *
+from .modulo_division import *
+from .square_root import *
+from .power_rule_differentiation import *
+from .square import *
+from .lcm import *
+from .gcd import *
+from .basic_algebra import *
+from .log import *
+from .int_division import *
+from .decimal_to_binary import *
+from .binary_to_decimal import *
+from .divide_fractions import *
+from .multiply_int_to_22_matrix import *
+from .area_of_triangle import *
+from .valid_triangle import *
+from .midpoint_of_two_points import *
+from .factoring import *
+from .third_angle_of_triangle import *
+from .system_of_equations import *
+from .distance_two_points import *
+from .pythagorean_theorem import *
+from .linear_equations import *
+from .prime_factors import *
+from .fraction_multiplication import *
+from .angle_regular_polygon import *
+from .combinations import *
+from .factorial import *
+from .surface_area_cube import *
+from .surface_area_cuboid import *
+from .surface_area_cylinder import *
+from .volume_cube import *
+from .volume_cuboid import *
+from .volume_cylinder import *
+from .surface_area_cone import *
+from .volume_cone import *
+from .common_factors import *
+from .intersection_of_two_lines import *
+from .permutation import *
+from .vector_cross import *
+from .compare_fractions import *
+from .simple_interest import *
+from .matrix_multiplication import *
+from .cube_root import *
+from .power_rule_integration import *
+from .fourth_angle_of_quadrilateral import *
+from .quadratic_equation import *
+from .hcf import *
+from .dice_sum_probability import *
+from .exponentiation import *
+from .confidence_interval import *
+from .surds_comparison import *
+from .fibonacci_series import *
+from .basic_trigonometry import *
+from .sum_of_polygon_angles import *
+from .data_summary import *
+from .surface_area_sphere import *
+from .volume_sphere import *
+from .nth_fibonacci_number import *
+from .profit_loss_percent import *
+from .binary_to_hex import *
+from .multiply_complex_numbers import *
+from .geometric_progression import *
+from .geometric_mean import *
+from .harmonic_mean import *
+from .euclidian_norm import *
+from .angle_btw_vectors import *
+from .absolute_difference import *
+from .vector_dot import *
+from .binary_2s_complement import *
+from .invert_matrix import *
+from .sector_area import *
+from .mean_median import *
+from .int_matrix_22_determinant import *
+from .compound_interest import *
+from .decimal_to_hexadeci import *
+from .percentage import *
+from .celsius_to_fahrenheit import *
+from .arithmetic_progression_term import *
+from .arithmetic_progression_sum import *
+from .decimal_to_octal import *
+from .decimal_to_roman_numerals import *
+from .degree_to_rad import *
+from .radian_to_deg import *
+from .differentiation import *
+from .definite_integral import *
+from .is_prime import *
+from .bcd_to_decimal import *
+from .complex_to_polar import *
diff --git a/mathgenerator/funcs/absoluteDifferenceFunc.py b/mathgenerator/funcs/absolute_difference.py
similarity index 88%
rename from mathgenerator/funcs/absoluteDifferenceFunc.py
rename to mathgenerator/funcs/absolute_difference.py
index 755e049..fae1fb0 100644
--- a/mathgenerator/funcs/absoluteDifferenceFunc.py
+++ b/mathgenerator/funcs/absolute_difference.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def absoluteDifferenceFunc(maxA=100, maxB=100):
@@ -13,7 +12,7 @@ def absoluteDifferenceFunc(maxA=100, maxB=100):
return problem, solution
-absoluteDifference = Generator(
+absolute_difference = Generator(
"Absolute difference between two numbers", 71,
"Absolute difference betweeen two numbers a and b =", "|a-b|",
absoluteDifferenceFunc)
diff --git a/mathgenerator/funcs/addition.py b/mathgenerator/funcs/addition.py
index df74496..cab6dac 100644
--- a/mathgenerator/funcs/addition.py
+++ b/mathgenerator/funcs/addition.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def additionFunc(maxSum=99, maxAddend=50):
diff --git a/mathgenerator/funcs/angleBtwVectorsFunc.py b/mathgenerator/funcs/angle_btw_vectors.py
similarity index 90%
rename from mathgenerator/funcs/angleBtwVectorsFunc.py
rename to mathgenerator/funcs/angle_btw_vectors.py
index 65ec973..f3b8a65 100644
--- a/mathgenerator/funcs/angleBtwVectorsFunc.py
+++ b/mathgenerator/funcs/angle_btw_vectors.py
@@ -1,5 +1,5 @@
from .__init__ import *
-from ..__init__ import Generator
+import math
def angleBtwVectorsFunc(maxEltAmt=20):
@@ -15,14 +15,14 @@ def angleBtwVectorsFunc(maxEltAmt=20):
solution = ''
try:
solution = str(math.acos(s / mags))
- except MathDomainError:
+ except ValueError:
print('angleBtwVectorsFunc has some issues with math module, line 16')
solution = 'NaN'
# would return the answer in radians
return problem, solution
-angleBtwVectors = Generator(
+angle_btw_vectors = 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)
diff --git a/mathgenerator/funcs/regularPolygonAngleFunc.py b/mathgenerator/funcs/angle_regular_polygon.py
similarity index 86%
rename from mathgenerator/funcs/regularPolygonAngleFunc.py
rename to mathgenerator/funcs/angle_regular_polygon.py
index a264c5a..90f2c71 100644
--- a/mathgenerator/funcs/regularPolygonAngleFunc.py
+++ b/mathgenerator/funcs/angle_regular_polygon.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def regularPolygonAngleFunc(minVal=3, maxVal=20):
@@ -11,7 +10,7 @@ def regularPolygonAngleFunc(minVal=3, maxVal=20):
return problem, solution
-angleRegularPolygon = Generator(
+angle_regular_polygon = Generator(
"Angle of a Regular Polygon", 29,
"Find the angle of a regular polygon with 6 sides", "120",
regularPolygonAngleFunc)
diff --git a/mathgenerator/funcs/areaOfTriangleFunc.py b/mathgenerator/funcs/area_of_triangle.py
similarity index 65%
rename from mathgenerator/funcs/areaOfTriangleFunc.py
rename to mathgenerator/funcs/area_of_triangle.py
index c49167c..488a997 100644
--- a/mathgenerator/funcs/areaOfTriangleFunc.py
+++ b/mathgenerator/funcs/area_of_triangle.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
@@ -16,6 +15,6 @@ def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
return problem, solution
-areaOfTriangle = Generator("Area of Triangle", 18,
- "Area of Triangle with side lengths a, b, c = ",
- "area", areaOfTriangleFunc)
+area_of_triangle = Generator("Area of Triangle", 18,
+ "Area of Triangle with side lengths a, b, c = ",
+ "area", areaOfTriangleFunc)
diff --git a/mathgenerator/funcs/arithmeticProgressionSumFunc.py b/mathgenerator/funcs/arithmetic_progression_sum.py
similarity index 63%
rename from mathgenerator/funcs/arithmeticProgressionSumFunc.py
rename to mathgenerator/funcs/arithmetic_progression_sum.py
index 294cb7f..e376c3f 100644
--- a/mathgenerator/funcs/arithmeticProgressionSumFunc.py
+++ b/mathgenerator/funcs/arithmetic_progression_sum.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
@@ -14,6 +13,6 @@ def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
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)
+arithmetic_progression_sum = Generator("AP Sum Calculation", 83,
+ "Find the sum of first n terms of the AP series: a1, a2, a3 ...",
+ "Sum", arithmeticProgressionSumFunc)
diff --git a/mathgenerator/funcs/arithmeticProgressionTermFunc.py b/mathgenerator/funcs/arithmetic_progression_term.py
similarity index 62%
rename from mathgenerator/funcs/arithmeticProgressionTermFunc.py
rename to mathgenerator/funcs/arithmetic_progression_term.py
index e549c18..8468921 100644
--- a/mathgenerator/funcs/arithmeticProgressionTermFunc.py
+++ b/mathgenerator/funcs/arithmetic_progression_term.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def arithmeticProgressionTermFunc(maxd=100, maxa=100, maxn=100):
@@ -14,6 +13,6 @@ def arithmeticProgressionTermFunc(maxd=100, maxa=100, maxn=100):
return problem, solution
-arithmeticProgressionTerm = Generator("AP Term Calculation", 82,
- "Find the term number n of the AP series: a1, a2, a3 ...",
- "a-n", arithmeticProgressionTermFunc)
+arithmetic_progression_term = Generator("AP Term Calculation", 82,
+ "Find the term number n of the AP series: a1, a2, a3 ...",
+ "a-n", arithmeticProgressionTermFunc)
diff --git a/mathgenerator/funcs/basicAlgebraFunc.py b/mathgenerator/funcs/basic_algebra.py
similarity index 79%
rename from mathgenerator/funcs/basicAlgebraFunc.py
rename to mathgenerator/funcs/basic_algebra.py
index 504ac41..0626cf8 100644
--- a/mathgenerator/funcs/basicAlgebraFunc.py
+++ b/mathgenerator/funcs/basic_algebra.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def basicAlgebraFunc(maxVariable=10):
@@ -26,5 +25,5 @@ def basicAlgebraFunc(maxVariable=10):
return problem, solution
-basicAlgebra = Generator("Basic Algebra", 11, "ax + b = c", "d",
- basicAlgebraFunc)
+basic_algebra = Generator("Basic Algebra", 11, "ax + b = c", "d",
+ basicAlgebraFunc)
diff --git a/mathgenerator/funcs/basicTrigonometryFunc.py b/mathgenerator/funcs/basic_trigonometry.py
similarity index 81%
rename from mathgenerator/funcs/basicTrigonometryFunc.py
rename to mathgenerator/funcs/basic_trigonometry.py
index da6d97c..2992034 100644
--- a/mathgenerator/funcs/basicTrigonometryFunc.py
+++ b/mathgenerator/funcs/basic_trigonometry.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
# Handles degrees in quadrant one
@@ -26,5 +25,5 @@ def basicTrigonometryFunc(angles=[0, 30, 45, 60, 90],
return problem, solution
-basicTrigonometry = Generator("Trigonometric Values", 57, "What is sin(X)?",
- "ans", basicTrigonometryFunc)
+basic_trigonometry = Generator("Trigonometric Values", 57, "What is sin(X)?",
+ "ans", basicTrigonometryFunc)
diff --git a/mathgenerator/funcs/bcd_to_decimal.py b/mathgenerator/funcs/bcd_to_decimal.py
new file mode 100644
index 0000000..fc356d0
--- /dev/null
+++ b/mathgenerator/funcs/bcd_to_decimal.py
@@ -0,0 +1,24 @@
+from .__init__ import *
+
+
+def BCDtoDecimalFunc(maxNumber=10000):
+ n = random.randint(1000, maxNumber)
+ binstring = ''
+ while True:
+ q, r = divmod(n, 10)
+ nibble = bin(r).replace('0b', "")
+ while len(nibble) < 4:
+ nibble = '0' + nibble
+ binstring = nibble + binstring
+ if q == 0:
+ break
+ else:
+ n = q
+
+ problem = "Integer of Binary Coded Decimal " + str(n) + " is = "
+ solution = int(binstring, 2)
+ return problem, solution
+
+
+bcd_to_decimal = Generator("Binary Coded Decimal to Integer", 91,
+ "Integer of Binary Coded Decimal b is ", "n", BCDtoDecimalFunc)
diff --git a/mathgenerator/funcs/binary2sComplement.py b/mathgenerator/funcs/binary_2s_complement.py
similarity index 76%
rename from mathgenerator/funcs/binary2sComplement.py
rename to mathgenerator/funcs/binary_2s_complement.py
index 891990d..f053020 100644
--- a/mathgenerator/funcs/binary2sComplement.py
+++ b/mathgenerator/funcs/binary_2s_complement.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def binary2sComplementFunc(maxDigits=10):
@@ -29,6 +28,6 @@ def binary2sComplementFunc(maxDigits=10):
return problem, solution
-binary2sComplement = Generator("Binary 2's Complement", 73,
- "2's complement of 11010110 =", "101010",
- binary2sComplementFunc)
+binary_2s_complement = Generator("Binary 2's Complement", 73,
+ "2's complement of 11010110 =", "101010",
+ binary2sComplementFunc)
diff --git a/mathgenerator/funcs/binaryComplement1sFunc.py b/mathgenerator/funcs/binary_complement_1s.py
similarity index 68%
rename from mathgenerator/funcs/binaryComplement1sFunc.py
rename to mathgenerator/funcs/binary_complement_1s.py
index f748af5..da6c481 100644
--- a/mathgenerator/funcs/binaryComplement1sFunc.py
+++ b/mathgenerator/funcs/binary_complement_1s.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def binaryComplement1sFunc(maxDigits=10):
@@ -16,5 +15,5 @@ def binaryComplement1sFunc(maxDigits=10):
return problem, solution
-binaryComplement1s = Generator("Binary Complement 1s", 4, "1010=", "0101",
- binaryComplement1sFunc)
+binary_complement_1s = Generator("Binary Complement 1s", 4, "1010=", "0101",
+ binaryComplement1sFunc)
diff --git a/mathgenerator/funcs/BinaryToDecimalFunc.py b/mathgenerator/funcs/binary_to_decimal.py
similarity index 53%
rename from mathgenerator/funcs/BinaryToDecimalFunc.py
rename to mathgenerator/funcs/binary_to_decimal.py
index 01fb780..f7e0aa8 100644
--- a/mathgenerator/funcs/BinaryToDecimalFunc.py
+++ b/mathgenerator/funcs/binary_to_decimal.py
@@ -1,8 +1,7 @@
from .__init__ import *
-from ..__init__ import Generator
-def BinaryToDecimalFunc(max_dig=10):
+def binaryToDecimalFunc(max_dig=10):
problem = ''
for i in range(random.randint(1, max_dig)):
@@ -13,5 +12,5 @@ def BinaryToDecimalFunc(max_dig=10):
return problem, solution
-binaryToDecimal = Generator("Binary to Decimal", 15, "Decimal of a=", "b",
- BinaryToDecimalFunc)
+binary_to_decimal = Generator("Binary to Decimal", 15, "Decimal of a=", "b",
+ binaryToDecimalFunc)
diff --git a/mathgenerator/funcs/binaryToHexFunc.py b/mathgenerator/funcs/binary_to_hex.py
similarity index 62%
rename from mathgenerator/funcs/binaryToHexFunc.py
rename to mathgenerator/funcs/binary_to_hex.py
index 12dbe7f..77b03b1 100644
--- a/mathgenerator/funcs/binaryToHexFunc.py
+++ b/mathgenerator/funcs/binary_to_hex.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def binaryToHexFunc(max_dig=10):
@@ -12,5 +11,5 @@ def binaryToHexFunc(max_dig=10):
return problem, solution
-binaryToHex = Generator("Binary to Hexidecimal", 64, "Hexidecimal of a=", "b",
- binaryToHexFunc)
+binary_to_hex = Generator("Binary to Hexidecimal", 64, "Hexidecimal of a=", "b",
+ binaryToHexFunc)
diff --git a/mathgenerator/funcs/celsiustofahrenheit.py b/mathgenerator/funcs/celsius_to_fahrenheit.py
similarity index 63%
rename from mathgenerator/funcs/celsiustofahrenheit.py
rename to mathgenerator/funcs/celsius_to_fahrenheit.py
index 0e66be8..45122d0 100644
--- a/mathgenerator/funcs/celsiustofahrenheit.py
+++ b/mathgenerator/funcs/celsius_to_fahrenheit.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def celsiustofahrenheitFunc(maxTemp=100):
@@ -10,5 +9,5 @@ def celsiustofahrenheitFunc(maxTemp=100):
return problem, solution
-celsiustofahrenheit = Generator("Celsius To Fahrenheit", 81,
- "(C +(9/5))+32=", "F", celsiustofahrenheitFunc)
+celsius_to_fahrenheit = Generator("Celsius To Fahrenheit", 81,
+ "(C +(9/5))+32=", "F", celsiustofahrenheitFunc)
diff --git a/mathgenerator/funcs/combinationsFunc.py b/mathgenerator/funcs/combinations.py
similarity index 95%
rename from mathgenerator/funcs/combinationsFunc.py
rename to mathgenerator/funcs/combinations.py
index ca42532..60c7b41 100644
--- a/mathgenerator/funcs/combinationsFunc.py
+++ b/mathgenerator/funcs/combinations.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def combinationsFunc(maxlength=20):
diff --git a/mathgenerator/funcs/commonFactorsFunc.py b/mathgenerator/funcs/common_factors.py
similarity index 70%
rename from mathgenerator/funcs/commonFactorsFunc.py
rename to mathgenerator/funcs/common_factors.py
index 929c48e..a783909 100644
--- a/mathgenerator/funcs/commonFactorsFunc.py
+++ b/mathgenerator/funcs/common_factors.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def commonFactorsFunc(maxVal=100):
@@ -25,6 +24,6 @@ def commonFactorsFunc(maxVal=100):
return problem, solution
-commonFactors = Generator("Common Factors", 40,
- "Common Factors of {a} and {b} = ", "[c, d, ...]",
- commonFactorsFunc)
+common_factors = Generator("Common Factors", 40,
+ "Common Factors of {a} and {b} = ", "[c, d, ...]",
+ commonFactorsFunc)
diff --git a/mathgenerator/funcs/compareFractionsFunc.py b/mathgenerator/funcs/compare_fractions.py
similarity index 92%
rename from mathgenerator/funcs/compareFractionsFunc.py
rename to mathgenerator/funcs/compare_fractions.py
index 19ba5c9..53fe7a0 100644
--- a/mathgenerator/funcs/compareFractionsFunc.py
+++ b/mathgenerator/funcs/compare_fractions.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def compareFractionsFunc(maxVal=10):
@@ -27,7 +26,7 @@ def compareFractionsFunc(maxVal=10):
return problem, solution
-compareFractions = Generator(
+compare_fractions = Generator(
"Compare Fractions", 44,
"Which symbol represents the comparison between a/b and c/d?", ">/=",
compareFractionsFunc)
diff --git a/mathgenerator/funcs/complex_to_polar.py b/mathgenerator/funcs/complex_to_polar.py
new file mode 100644
index 0000000..ecab5ec
--- /dev/null
+++ b/mathgenerator/funcs/complex_to_polar.py
@@ -0,0 +1,18 @@
+from .__init__ import *
+
+
+def complexToPolarFunc(minRealImaginaryNum=-20, maxRealImaginaryNum=20):
+ num = complex(random.randint(minRealImaginaryNum, maxRealImaginaryNum),
+ random.randint(minRealImaginaryNum, maxRealImaginaryNum))
+ a = num.real
+ b = num.imag
+ r = round(math.hypot(a, b), 2)
+ theta = round(math.atan2(b, a), 2)
+ plr = str(r) + "exp(i" + str(theta) + ")"
+ problem = f"rexp(itheta) = "
+ solution = plr
+ return problem, solution
+
+
+complex_to_polar = Generator("Complex To Polar Form", 92,
+ "rexp(itheta) = ", "plr", complexToPolarFunc)
diff --git a/mathgenerator/funcs/compoundInterestFunc.py b/mathgenerator/funcs/compoundInterestFunc.py
deleted file mode 100644
index 60a3f40..0000000
--- a/mathgenerator/funcs/compoundInterestFunc.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from .__init__ import *
-from ..__init__ import Generator
-
-
-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
-
-
-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)
diff --git a/mathgenerator/funcs/compound_interest.py b/mathgenerator/funcs/compound_interest.py
new file mode 100644
index 0000000..8f7d48d
--- /dev/null
+++ b/mathgenerator/funcs/compound_interest.py
@@ -0,0 +1,17 @@
+from .__init__ import *
+
+
+def compoundInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
+ p = random.randint(1000, maxPrinciple)
+ r = random.randint(1, maxRate)
+ n = random.randint(1, maxTime)
+ a = p * (1 + r / 100)**n
+ problem = "Compound interest for a principle amount of " + \
+ str(p) + " dollars, " + str(r) + \
+ "% rate of interest and for a time period of " + str(n) + " year is = "
+ solution = round(a, 2)
+ return problem, solution
+
+
+compound_interest = Generator(
+ "Compound Interest", 78, "Compound interest for a principle amount of a dollars, b% rate of interest and for a time period of c years is = ", "d dollars", compoundInterestFunc)
diff --git a/mathgenerator/funcs/confidenceIntervalFunc.py b/mathgenerator/funcs/confidence_interval.py
similarity index 76%
rename from mathgenerator/funcs/confidenceIntervalFunc.py
rename to mathgenerator/funcs/confidence_interval.py
index 9b13c81..e6cb161 100644
--- a/mathgenerator/funcs/confidenceIntervalFunc.py
+++ b/mathgenerator/funcs/confidence_interval.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def confidenceIntervalFunc():
@@ -32,6 +31,6 @@ def confidenceIntervalFunc():
return problem, solution
-confidenceInterval = Generator("Confidence interval For sample S", 54,
- "With X% confidence", "is (A,B)",
- confidenceIntervalFunc)
+confidence_interval = Generator("Confidence interval For sample S", 54,
+ "With X% confidence", "is (A,B)",
+ confidenceIntervalFunc)
diff --git a/mathgenerator/funcs/cubeRootFunc.py b/mathgenerator/funcs/cube_root.py
similarity index 62%
rename from mathgenerator/funcs/cubeRootFunc.py
rename to mathgenerator/funcs/cube_root.py
index 3f18831..041d492 100644
--- a/mathgenerator/funcs/cubeRootFunc.py
+++ b/mathgenerator/funcs/cube_root.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def cubeRootFunc(minNo=1, maxNo=1000):
@@ -11,5 +10,5 @@ def cubeRootFunc(minNo=1, maxNo=1000):
return problem, solution
-CubeRoot = Generator("Cube Root", 47, "Cuberoot of a upto 2 decimal places is",
- "b", cubeRootFunc)
+cube_root = Generator("Cube Root", 47, "Cuberoot of a upto 2 decimal places is",
+ "b", cubeRootFunc)
diff --git a/mathgenerator/funcs/dataSummaryFunc.py b/mathgenerator/funcs/data_summary.py
similarity index 60%
rename from mathgenerator/funcs/dataSummaryFunc.py
rename to mathgenerator/funcs/data_summary.py
index cd5db00..a84a91c 100644
--- a/mathgenerator/funcs/dataSummaryFunc.py
+++ b/mathgenerator/funcs/data_summary.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def dataSummaryFunc(number_values=15, minval=5, maxval=50):
@@ -16,18 +15,15 @@ def dataSummaryFunc(number_values=15, minval=5, maxval=50):
for i in range(number_values):
var += (random_list[i] - mean)**2
- # we're printing stuff here?
- print(random_list)
- print(mean)
- print(var / number_values)
- print((var / number_values)**0.5)
+ standardDeviation = var / number_values
+ variance = (var / number_values) ** 0.5
problem = "Find the mean,standard deviation and variance for the data" + \
str(random_list)
solution = "The Mean is {} , Standard Deviation is {}, Variance is {}".format(
- mean, var / number_values, (var / number_values)**0.5)
+ mean, standardDeviation, variance)
return problem, solution
-dataSummary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c",
- "Mean:a+b+c/3,Std,Var", dataSummaryFunc)
+data_summary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c",
+ "Mean:a+b+c/3,Std,Var", dataSummaryFunc)
diff --git a/mathgenerator/funcs/DecimalToBinaryFunc.py b/mathgenerator/funcs/decimal_to_binary.py
similarity index 59%
rename from mathgenerator/funcs/DecimalToBinaryFunc.py
rename to mathgenerator/funcs/decimal_to_binary.py
index a2aa043..354b9d4 100644
--- a/mathgenerator/funcs/DecimalToBinaryFunc.py
+++ b/mathgenerator/funcs/decimal_to_binary.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def DecimalToBinaryFunc(max_dec=99):
@@ -12,5 +11,5 @@ def DecimalToBinaryFunc(max_dec=99):
return problem, solution
-decimalToBinary = Generator("Decimal to Binary", 14, "Binary of a=", "b",
- DecimalToBinaryFunc)
+decimal_to_binary = Generator("Decimal to Binary", 14, "Binary of a=", "b",
+ DecimalToBinaryFunc)
diff --git a/mathgenerator/funcs/deciToHexaFunc.py b/mathgenerator/funcs/decimal_to_hexadeci.py
similarity index 56%
rename from mathgenerator/funcs/deciToHexaFunc.py
rename to mathgenerator/funcs/decimal_to_hexadeci.py
index e1ac230..57e753b 100644
--- a/mathgenerator/funcs/deciToHexaFunc.py
+++ b/mathgenerator/funcs/decimal_to_hexadeci.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def deciToHexaFunc(max_dec=1000):
@@ -11,5 +10,5 @@ def deciToHexaFunc(max_dec=1000):
return problem, solution
-decimalToHexadeci = Generator("Decimal to Hexadecimal", 79, "Binary of a=",
- "b", deciToHexaFunc)
+decimal_to_hexadeci = Generator("Decimal to Hexadecimal", 79, "Binary of a=",
+ "b", deciToHexaFunc)
diff --git a/mathgenerator/funcs/decimalToOctalFunc.py b/mathgenerator/funcs/decimal_to_octal.py
similarity index 57%
rename from mathgenerator/funcs/decimalToOctalFunc.py
rename to mathgenerator/funcs/decimal_to_octal.py
index 4a5c7ab..5a89b99 100644
--- a/mathgenerator/funcs/decimalToOctalFunc.py
+++ b/mathgenerator/funcs/decimal_to_octal.py
@@ -8,5 +8,5 @@ def decimalToOctalFunc(maxDecimal=4096):
return problem, solution
-decimalToOctal = Generator("Converts decimal to octal", 84,
- "What's the octal representation of 98?", "0o142", decimalToOctalFunc)
+decimal_to_octal = Generator("Converts decimal to octal", 84,
+ "What's the octal representation of 98?", "0o142", decimalToOctalFunc)
diff --git a/mathgenerator/funcs/decimalToRomanNumeralsFunc.py b/mathgenerator/funcs/decimal_to_roman_numerals.py
similarity index 77%
rename from mathgenerator/funcs/decimalToRomanNumeralsFunc.py
rename to mathgenerator/funcs/decimal_to_roman_numerals.py
index 03e369b..63b64f2 100644
--- a/mathgenerator/funcs/decimalToRomanNumeralsFunc.py
+++ b/mathgenerator/funcs/decimal_to_roman_numerals.py
@@ -15,7 +15,7 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000):
if last_value <= 3:
solution += (roman_dict[divisor] * last_value)
elif last_value == 4:
- solution += (roman_dict[divisor] * roman_dict[divisor * 5])
+ 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:
@@ -25,5 +25,5 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000):
return problem, solution
-decimalToRomanNumerals = Generator("Converts decimal to Roman Numerals",
- 85, "Convert 20 into Roman Numerals", "XX", decimalToRomanNumeralsFunc)
+decimal_to_roman_numerals = Generator("Converts decimal to Roman Numerals",
+ 85, "Convert 20 into Roman Numerals", "XX", decimalToRomanNumeralsFunc)
diff --git a/mathgenerator/funcs/definite_integral.py b/mathgenerator/funcs/definite_integral.py
new file mode 100644
index 0000000..6e8453f
--- /dev/null
+++ b/mathgenerator/funcs/definite_integral.py
@@ -0,0 +1,27 @@
+from .__init__ import *
+import scipy
+from scipy.integrate import quad
+
+
+def definiteIntegralFunc(max_coeff=100):
+
+ def integrand(x, a, b, c):
+ return a * x ** 2 + b * x + c
+
+ a = random.randint(0, max_coeff)
+ b = random.randint(0, max_coeff)
+ c = random.randint(0, max_coeff)
+
+ result = quad(integrand, 0, 1, args=(a, b, c))[0]
+ S = round(result, 4)
+
+ problem = "The definite integral within limits 0 to 1 of the equation " + \
+ str(a) + "x^2 + " + str(b) + "x + " + str(c) + " is = "
+
+ solution = str(S)
+
+ return problem, solution
+
+
+definite_integral = Generator("Definite Integral of Quadratic Equation", 89,
+ "The definite integral within limits 0 to 1 of quadratic equation ax^2+bx+c is = ", "S", definiteIntegralFunc)
diff --git a/mathgenerator/funcs/degreeToRadFunc.py b/mathgenerator/funcs/degree_to_rad.py
similarity index 67%
rename from mathgenerator/funcs/degreeToRadFunc.py
rename to mathgenerator/funcs/degree_to_rad.py
index 7ca4080..dc63f10 100644
--- a/mathgenerator/funcs/degreeToRadFunc.py
+++ b/mathgenerator/funcs/degree_to_rad.py
@@ -13,4 +13,5 @@ def degreeToRadFunc(max_deg=360):
return problem, solution
-degreeToRad = Generator("Degrees to Radians", 86, "Angle a in radians is = ", "b", degreeToRadFunc)
+degree_to_rad = Generator("Degrees to Radians", 86,
+ "Angle a in radians is = ", "b", degreeToRadFunc)
diff --git a/mathgenerator/funcs/DiceSumProbFunc.py b/mathgenerator/funcs/dice_sum_probability.py
similarity index 93%
rename from mathgenerator/funcs/DiceSumProbFunc.py
rename to mathgenerator/funcs/dice_sum_probability.py
index 720490e..d5139e4 100644
--- a/mathgenerator/funcs/DiceSumProbFunc.py
+++ b/mathgenerator/funcs/dice_sum_probability.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def DiceSumProbFunc(maxDice=3):
@@ -27,7 +26,7 @@ def DiceSumProbFunc(maxDice=3):
return problem, solution
-diceSumProbability = Generator(
+dice_sum_probability = 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)
diff --git a/mathgenerator/funcs/differentiation.py b/mathgenerator/funcs/differentiation.py
new file mode 100644
index 0000000..2b40dea
--- /dev/null
+++ b/mathgenerator/funcs/differentiation.py
@@ -0,0 +1,53 @@
+from .__init__ import *
+
+
+def genDifferentiationProblem(diff_lvl):
+ problem = ''
+
+ types = {
+ 'Logrithmic': ['ln'],
+ 'Trigonometric': ['sin', 'cos', 'tan', 'cot', 'sec'],
+ 'Exponentional': ['exp']
+ }
+
+ if diff_lvl == 1:
+ coeff = random.randrange(2, 10)
+ power = random.randint(2, 4)
+ flag = random.random()
+ if flag > 0.5:
+ power *= -1
+ problem += str(coeff) + '*x^' + '(' + str(power) + ')'
+ else:
+ problem += str(coeff) + '*x^' + str(power)
+ if diff_lvl == 2:
+ func_type = random.choices(list(types.keys()), weights=(1, 4, 1))[0]
+ func = random.choice(types[func_type])
+ problem += func + '(x)' + '+' + genDifferentiationProblem(1)
+ if diff_lvl == 3:
+ func_type = random.choices(list(types.keys()), weights=(1, 4, 1))[0]
+ func = random.choice(types[func_type])
+ problem += func + '(' + genDifferentiationProblem(1) + ')'
+ if diff_lvl == 4:
+ operator = random.choice(('/', '*'))
+ problem = '(' + genDifferentiationProblem(2) + ')' + \
+ operator + '(' + genDifferentiationProblem(3) + ')'
+
+ return problem
+
+
+def differentiationFunc(diff_lvl=2):
+ if diff_lvl < 1 or diff_lvl > 4:
+ print("diff_lvl not supported")
+ return None
+ problem = genDifferentiationProblem(diff_lvl)
+
+ x = sympy.symbols('x')
+ solution = str(sympy.diff(problem.replace('^', '**'), x))
+ solution = solution.replace('**', '^')
+ problem = f"differentiate w.r.t x : d({problem})/dx"
+
+ return problem, solution
+
+
+differentiation = Generator(
+ "Differentiation", 88, "differentiate w.r.t x : d(f(x))/dx", "g(x)", differentiationFunc)
diff --git a/mathgenerator/funcs/distanceTwoPointsFunc.py b/mathgenerator/funcs/distance_two_points.py
similarity index 68%
rename from mathgenerator/funcs/distanceTwoPointsFunc.py
rename to mathgenerator/funcs/distance_two_points.py
index e5de6ae..6dc6b7d 100644
--- a/mathgenerator/funcs/distanceTwoPointsFunc.py
+++ b/mathgenerator/funcs/distance_two_points.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
@@ -15,6 +14,6 @@ def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
return problem, solution
-distance2Point = Generator("Distance between 2 points", 24,
- "Find the distance between (x1,y1) and (x2,y2)",
- "sqrt(distanceSquared)", distanceTwoPointsFunc)
+distance_two_points = Generator("Distance between 2 points", 24,
+ "Find the distance between (x1,y1) and (x2,y2)",
+ "sqrt(distanceSquared)", distanceTwoPointsFunc)
diff --git a/mathgenerator/funcs/divideFractionsFunc.py b/mathgenerator/funcs/divide_fractions.py
similarity index 88%
rename from mathgenerator/funcs/divideFractionsFunc.py
rename to mathgenerator/funcs/divide_fractions.py
index 6d90b77..e9a9ec4 100644
--- a/mathgenerator/funcs/divideFractionsFunc.py
+++ b/mathgenerator/funcs/divide_fractions.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def divideFractionsFunc(maxVal=10):
@@ -33,5 +32,5 @@ def divideFractionsFunc(maxVal=10):
return problem, solution
-fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y",
+divide_fractions = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y",
divideFractionsFunc)
diff --git a/mathgenerator/funcs/divisionFunc.py b/mathgenerator/funcs/division.py
similarity index 90%
rename from mathgenerator/funcs/divisionFunc.py
rename to mathgenerator/funcs/division.py
index a99d9f7..63e70cb 100644
--- a/mathgenerator/funcs/divisionFunc.py
+++ b/mathgenerator/funcs/division.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def divisionFunc(maxRes=99, maxDivid=99):
diff --git a/mathgenerator/funcs/euclidianNormFunc.py b/mathgenerator/funcs/euclidian_norm.py
similarity index 52%
rename from mathgenerator/funcs/euclidianNormFunc.py
rename to mathgenerator/funcs/euclidian_norm.py
index 9b66167..cfd178c 100644
--- a/mathgenerator/funcs/euclidianNormFunc.py
+++ b/mathgenerator/funcs/euclidian_norm.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def euclidianNormFunc(maxEltAmt=20):
@@ -9,6 +8,6 @@ def euclidianNormFunc(maxEltAmt=20):
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)
+eucldian_norm = 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)
diff --git a/mathgenerator/funcs/exponentiationFunc.py b/mathgenerator/funcs/exponentiation.py
similarity index 91%
rename from mathgenerator/funcs/exponentiationFunc.py
rename to mathgenerator/funcs/exponentiation.py
index 1b4cc0c..dd764e4 100644
--- a/mathgenerator/funcs/exponentiationFunc.py
+++ b/mathgenerator/funcs/exponentiation.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def exponentiationFunc(maxBase=20, maxExpo=10):
diff --git a/mathgenerator/funcs/factorialFunc.py b/mathgenerator/funcs/factorial.py
similarity index 90%
rename from mathgenerator/funcs/factorialFunc.py
rename to mathgenerator/funcs/factorial.py
index 463d936..15d1e9d 100644
--- a/mathgenerator/funcs/factorialFunc.py
+++ b/mathgenerator/funcs/factorial.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def factorialFunc(maxInput=6):
diff --git a/mathgenerator/funcs/factoringFunc.py b/mathgenerator/funcs/factoring.py
similarity index 95%
rename from mathgenerator/funcs/factoringFunc.py
rename to mathgenerator/funcs/factoring.py
index a0ef82e..170a764 100644
--- a/mathgenerator/funcs/factoringFunc.py
+++ b/mathgenerator/funcs/factoring.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def factoringFunc(range_x1=10, range_x2=10):
diff --git a/mathgenerator/funcs/fibonacciSeriesFunc.py b/mathgenerator/funcs/fibonacci_series.py
similarity index 91%
rename from mathgenerator/funcs/fibonacciSeriesFunc.py
rename to mathgenerator/funcs/fibonacci_series.py
index 117befd..d81c782 100644
--- a/mathgenerator/funcs/fibonacciSeriesFunc.py
+++ b/mathgenerator/funcs/fibonacci_series.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def fibonacciSeriesFunc(minNo=1):
@@ -22,6 +21,6 @@ def fibonacciSeriesFunc(minNo=1):
return problem, solution
-fibonacciSeries = Generator(
+fibonacci_series = Generator(
"Fibonacci Series", 56, "fibonacci series of first a numbers",
"prints the fibonacci series starting from 0 to a", fibonacciSeriesFunc)
diff --git a/mathgenerator/funcs/fourthAngleOfQuadriFunc.py b/mathgenerator/funcs/fourth_angle_of_quadrilateral.py
similarity index 88%
rename from mathgenerator/funcs/fourthAngleOfQuadriFunc.py
rename to mathgenerator/funcs/fourth_angle_of_quadrilateral.py
index 871b725..1ecc9aa 100644
--- a/mathgenerator/funcs/fourthAngleOfQuadriFunc.py
+++ b/mathgenerator/funcs/fourth_angle_of_quadrilateral.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def fourthAngleOfQuadriFunc(maxAngle=180):
@@ -15,7 +14,7 @@ def fourthAngleOfQuadriFunc(maxAngle=180):
return problem, solution
-fourthAngleOfQuadrilateral = Generator(
+fourth_angle_of_quadrilateral = Generator(
"Fourth Angle of Quadrilateral", 49,
"Fourth angle of Quadrilateral with angles a,b,c =", "angle4",
fourthAngleOfQuadriFunc)
diff --git a/mathgenerator/funcs/multiplyFractionsFunc.py b/mathgenerator/funcs/fraction_multiplication.py
similarity index 75%
rename from mathgenerator/funcs/multiplyFractionsFunc.py
rename to mathgenerator/funcs/fraction_multiplication.py
index 39857c4..5c11940 100644
--- a/mathgenerator/funcs/multiplyFractionsFunc.py
+++ b/mathgenerator/funcs/fraction_multiplication.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def multiplyFractionsFunc(maxVal=10):
@@ -33,6 +32,6 @@ def multiplyFractionsFunc(maxVal=10):
return problem, solution
-fractionMultiplication = Generator("Fraction Multiplication", 28,
- "(a/b)*(c/d)=", "x/y",
- multiplyFractionsFunc)
+fraction_multiplication = Generator("Fraction Multiplication", 28,
+ "(a/b)*(c/d)=", "x/y",
+ multiplyFractionsFunc)
diff --git a/mathgenerator/funcs/gcdFunc.py b/mathgenerator/funcs/gcd.py
similarity index 91%
rename from mathgenerator/funcs/gcdFunc.py
rename to mathgenerator/funcs/gcd.py
index 4f271d1..ef1914b 100644
--- a/mathgenerator/funcs/gcdFunc.py
+++ b/mathgenerator/funcs/gcd.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def gcdFunc(maxVal=20):
diff --git a/mathgenerator/funcs/geometricMeanFunc.py b/mathgenerator/funcs/geometric_mean.py
similarity index 78%
rename from mathgenerator/funcs/geometricMeanFunc.py
rename to mathgenerator/funcs/geometric_mean.py
index ad80594..034ddf2 100644
--- a/mathgenerator/funcs/geometricMeanFunc.py
+++ b/mathgenerator/funcs/geometric_mean.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def geometricMeanFunc(maxValue=100, maxNum=4):
@@ -28,6 +27,6 @@ def geometricMeanFunc(maxValue=100, maxNum=4):
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)
+geometric_mean = Generator("Geometric Mean of N Numbers", 67,
+ "Geometric mean of n numbers A1 , A2 , ... , An = ",
+ "(A1*A2*...An)^(1/n) = ans", geometricMeanFunc)
diff --git a/mathgenerator/funcs/geomProgrFunc.py b/mathgenerator/funcs/geometric_progression.py
similarity index 94%
rename from mathgenerator/funcs/geomProgrFunc.py
rename to mathgenerator/funcs/geometric_progression.py
index 0683c3c..7c5c8f3 100644
--- a/mathgenerator/funcs/geomProgrFunc.py
+++ b/mathgenerator/funcs/geometric_progression.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def geomProgrFunc(number_values=6,
@@ -24,7 +23,7 @@ def geomProgrFunc(number_values=6,
return problem, solution
-geometricprogression = Generator(
+geometric_progression = Generator(
"Geometric Progression", 66,
"Initial value,Common Ratio,nth Term,Sum till nth term =",
"a,r,ar^n-1,sum(ar^n-1", geomProgrFunc)
diff --git a/mathgenerator/funcs/harmonicMeanFunc.py b/mathgenerator/funcs/harmonic_mean.py
similarity index 77%
rename from mathgenerator/funcs/harmonicMeanFunc.py
rename to mathgenerator/funcs/harmonic_mean.py
index 5febc7e..179c061 100644
--- a/mathgenerator/funcs/harmonicMeanFunc.py
+++ b/mathgenerator/funcs/harmonic_mean.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def harmonicMeanFunc(maxValue=100, maxNum=4):
@@ -29,7 +28,7 @@ def harmonicMeanFunc(maxValue=100, maxNum=4):
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)
+harmonic_mean = Generator("Harmonic Mean of N Numbers", 68,
+ "Harmonic mean of n numbers A1 , A2 , ... , An = ",
+ " n/((1/A1) + (1/A2) + ... + (1/An)) = ans",
+ harmonicMeanFunc)
diff --git a/mathgenerator/funcs/hcfFunc.py b/mathgenerator/funcs/hcf.py
similarity index 91%
rename from mathgenerator/funcs/hcfFunc.py
rename to mathgenerator/funcs/hcf.py
index aaab950..f9a0366 100644
--- a/mathgenerator/funcs/hcfFunc.py
+++ b/mathgenerator/funcs/hcf.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def hcfFunc(maxVal=20):
diff --git a/mathgenerator/funcs/divisionToIntFunc.py b/mathgenerator/funcs/int_division.py
similarity index 73%
rename from mathgenerator/funcs/divisionToIntFunc.py
rename to mathgenerator/funcs/int_division.py
index fa0514b..65cfd08 100644
--- a/mathgenerator/funcs/divisionToIntFunc.py
+++ b/mathgenerator/funcs/int_division.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def divisionToIntFunc(maxA=25, maxB=25):
@@ -14,4 +13,4 @@ def divisionToIntFunc(maxA=25, maxB=25):
return problem, solution
-intDivision = Generator("Easy Division", 13, "a/b=", "c", divisionToIntFunc)
+int_division = Generator("Easy Division", 13, "a/b=", "c", divisionToIntFunc)
diff --git a/mathgenerator/funcs/determinantToMatrix22.py b/mathgenerator/funcs/int_matrix_22_determinant.py
similarity index 61%
rename from mathgenerator/funcs/determinantToMatrix22.py
rename to mathgenerator/funcs/int_matrix_22_determinant.py
index 0117389..4e3d3ca 100644
--- a/mathgenerator/funcs/determinantToMatrix22.py
+++ b/mathgenerator/funcs/int_matrix_22_determinant.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def determinantToMatrix22(maxMatrixVal=100):
@@ -14,6 +13,6 @@ def determinantToMatrix22(maxMatrixVal=100):
return problem, solution
-intMatrix22determinant = Generator("Determinant to 2x2 Matrix", 77,
- "Det([[a,b],[c,d]]) =", " a * d - b * c",
- determinantToMatrix22)
+int_matrix_22_determinant = Generator("Determinant to 2x2 Matrix", 77,
+ "Det([[a,b],[c,d]]) =", " a * d - b * c",
+ determinantToMatrix22)
diff --git a/mathgenerator/funcs/intersectionOfTwoLinesFunc.py b/mathgenerator/funcs/intersection_of_two_lines.py
similarity index 97%
rename from mathgenerator/funcs/intersectionOfTwoLinesFunc.py
rename to mathgenerator/funcs/intersection_of_two_lines.py
index 4697201..c53f6be 100644
--- a/mathgenerator/funcs/intersectionOfTwoLinesFunc.py
+++ b/mathgenerator/funcs/intersection_of_two_lines.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def intersectionOfTwoLinesFunc(minM=-10,
@@ -67,7 +66,7 @@ def intersectionOfTwoLinesFunc(minM=-10,
return problem, solution
-intersectionOfTwoLines = Generator(
+intersection_of_two_lines = 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)
diff --git a/mathgenerator/funcs/matrixInversion.py b/mathgenerator/funcs/invert_matrix.py
similarity index 94%
rename from mathgenerator/funcs/matrixInversion.py
rename to mathgenerator/funcs/invert_matrix.py
index 4eb2787..7a196c5 100644
--- a/mathgenerator/funcs/matrixInversion.py
+++ b/mathgenerator/funcs/invert_matrix.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
import sympy
@@ -79,5 +78,5 @@ def matrixInversion(SquareMatrixDimension=3,
return problem, solution
-invertmatrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is",
- "A^(-1)", matrixInversion)
+invert_matrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is",
+ "A^(-1)", matrixInversion)
diff --git a/mathgenerator/funcs/is_prime.py b/mathgenerator/funcs/is_prime.py
new file mode 100644
index 0000000..143f4d3
--- /dev/null
+++ b/mathgenerator/funcs/is_prime.py
@@ -0,0 +1,22 @@
+from .__init__ import *
+
+
+def isprime(max_a=100):
+ a = random.randint(2, max_a)
+ problem = a
+ if a == 2:
+ solution = True
+ return (problem, solution)
+ if a % 2 == 0:
+ solution = False
+ return (problem, solution)
+ for i in range(3, a // 2 + 1, 2):
+ if a % i == 0:
+ solution = False
+ return (problem, solution)
+ solution = True
+ return (problem, solution)
+
+
+is_prime = Generator('isprime', 90, 'a any positive integer',
+ 'True/False', isprime)
diff --git a/mathgenerator/funcs/lcmFunc.py b/mathgenerator/funcs/lcm.py
similarity index 92%
rename from mathgenerator/funcs/lcmFunc.py
rename to mathgenerator/funcs/lcm.py
index ef57c2c..c786b52 100644
--- a/mathgenerator/funcs/lcmFunc.py
+++ b/mathgenerator/funcs/lcm.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def lcmFunc(maxVal=20):
diff --git a/mathgenerator/funcs/linearEquationsFunc.py b/mathgenerator/funcs/linear_equations.py
similarity index 80%
rename from mathgenerator/funcs/linearEquationsFunc.py
rename to mathgenerator/funcs/linear_equations.py
index 62dc081..7fb71b6 100644
--- a/mathgenerator/funcs/linearEquationsFunc.py
+++ b/mathgenerator/funcs/linear_equations.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def linearEquationsFunc(n=2, varRange=20, coeffRange=20):
@@ -26,9 +25,10 @@ def linearEquationsFunc(n=2, varRange=20, coeffRange=20):
prob = " + ".join(prob) + " = " + str(res)
problem.append(prob)
- problem = "\n".join(problem)
+ # problem = "\n".join(problem)
+ problem = ", ".join(problem)
return problem, solution
-linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12",
- "x=-20 & y=12", linearEquationsFunc)
+linear_equations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12",
+ "x=-20 & y=12", linearEquationsFunc)
diff --git a/mathgenerator/funcs/logFunc.py b/mathgenerator/funcs/log.py
similarity index 90%
rename from mathgenerator/funcs/logFunc.py
rename to mathgenerator/funcs/log.py
index dcc7c05..bc147f2 100644
--- a/mathgenerator/funcs/logFunc.py
+++ b/mathgenerator/funcs/log.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def logFunc(maxBase=3, maxVal=8):
diff --git a/mathgenerator/funcs/matrixMultiplicationFunc.py b/mathgenerator/funcs/matrix_multiplication.py
similarity index 85%
rename from mathgenerator/funcs/matrixMultiplicationFunc.py
rename to mathgenerator/funcs/matrix_multiplication.py
index 9706782..51c60f9 100644
--- a/mathgenerator/funcs/matrixMultiplicationFunc.py
+++ b/mathgenerator/funcs/matrix_multiplication.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def matrixMultiplicationFunc(maxVal=100, max_dim=10):
@@ -54,6 +53,6 @@ def matrixMultiplicationFuncHelper(inp):
return string
-matrixMultiplication = Generator("Multiplication of two matrices", 46,
- "Multiply two matrices A and B", "C",
- matrixMultiplicationFunc)
+matrix_multiplication = Generator("Multiplication of two matrices", 46,
+ "Multiply two matrices A and B", "C",
+ matrixMultiplicationFunc)
diff --git a/mathgenerator/funcs/meanMedianFunc.py b/mathgenerator/funcs/mean_median.py
similarity index 71%
rename from mathgenerator/funcs/meanMedianFunc.py
rename to mathgenerator/funcs/mean_median.py
index cd20310..91295c7 100644
--- a/mathgenerator/funcs/meanMedianFunc.py
+++ b/mathgenerator/funcs/mean_median.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def meanMedianFunc(maxlen=10):
@@ -15,6 +14,6 @@ def meanMedianFunc(maxlen=10):
return problem, solution
-meanMedian = Generator("Mean and Median", 76,
- "Mean and median of given set of numbers",
- "Mean, Median", meanMedianFunc)
+mean_median = Generator("Mean and Median", 76,
+ "Mean and median of given set of numbers",
+ "Mean, Median", meanMedianFunc)
diff --git a/mathgenerator/funcs/MidPointOfTwoPointFunc.py b/mathgenerator/funcs/midpoint_of_two_points.py
similarity index 59%
rename from mathgenerator/funcs/MidPointOfTwoPointFunc.py
rename to mathgenerator/funcs/midpoint_of_two_points.py
index 1a126b2..2b021aa 100644
--- a/mathgenerator/funcs/MidPointOfTwoPointFunc.py
+++ b/mathgenerator/funcs/midpoint_of_two_points.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def MidPointOfTwoPointFunc(maxValue=20):
@@ -13,6 +12,6 @@ def MidPointOfTwoPointFunc(maxValue=20):
return problem, solution
-midPointOfTwoPoint = Generator("Midpoint of the two point", 20,
- "((X1,Y1),(X2,Y2))=", "((X1+X2)/2,(Y1+Y2)/2)",
- MidPointOfTwoPointFunc)
+midPoint_of_two_points = Generator("Midpoint of the two point", 20,
+ "((X1,Y1),(X2,Y2))=", "((X1+X2)/2,(Y1+Y2)/2)",
+ MidPointOfTwoPointFunc)
diff --git a/mathgenerator/funcs/moduloFunc.py b/mathgenerator/funcs/modulo_division.py
similarity index 72%
rename from mathgenerator/funcs/moduloFunc.py
rename to mathgenerator/funcs/modulo_division.py
index 3d97d52..12f07a2 100644
--- a/mathgenerator/funcs/moduloFunc.py
+++ b/mathgenerator/funcs/modulo_division.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def moduloFunc(maxRes=99, maxModulo=99):
@@ -12,4 +11,4 @@ def moduloFunc(maxRes=99, maxModulo=99):
return problem, solution
-moduloDivision = Generator("Modulo Division", 5, "a%b=", "c", moduloFunc)
+modulo_division = Generator("Modulo Division", 5, "a%b=", "c", moduloFunc)
diff --git a/mathgenerator/funcs/multiplicationFunc.py b/mathgenerator/funcs/multiplication.py
similarity index 72%
rename from mathgenerator/funcs/multiplicationFunc.py
rename to mathgenerator/funcs/multiplication.py
index 1d1d339..7e6e36e 100644
--- a/mathgenerator/funcs/multiplicationFunc.py
+++ b/mathgenerator/funcs/multiplication.py
@@ -1,10 +1,12 @@
from .__init__ import *
-from ..__init__ import Generator
def multiplicationFunc(maxRes=99, maxMulti=99):
a = random.randint(0, maxMulti)
- b = random.randint(0, min(int(maxMulti / a), maxRes))
+ if a == 0:
+ b = random.randint(0, maxRes)
+ else:
+ b = random.randint(0, min(int(maxMulti / a), maxRes))
c = a * b
problem = str(a) + "*" + str(b) + "="
diff --git a/mathgenerator/funcs/multiplyComplexNumbersFunc.py b/mathgenerator/funcs/multiply_complex_numbers.py
similarity index 69%
rename from mathgenerator/funcs/multiplyComplexNumbersFunc.py
rename to mathgenerator/funcs/multiply_complex_numbers.py
index 8f825d0..03762e8 100644
--- a/mathgenerator/funcs/multiplyComplexNumbersFunc.py
+++ b/mathgenerator/funcs/multiply_complex_numbers.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def multiplyComplexNumbersFunc(minRealImaginaryNum=-20,
@@ -13,6 +12,6 @@ def multiplyComplexNumbersFunc(minRealImaginaryNum=-20,
return problem, solution
-complexNumMultiply = Generator("Multiplication of 2 complex numbers", 65,
- "(x + j) (y + j) = ", "xy + xj + yj -1",
- multiplyComplexNumbersFunc)
+multiply_complex_numbers = Generator("Multiplication of 2 complex numbers", 65,
+ "(x + j) (y + j) = ", "xy + xj + yj -1",
+ multiplyComplexNumbersFunc)
diff --git a/mathgenerator/funcs/multiplyIntToMatrix22.py b/mathgenerator/funcs/multiply_int_to_22_matrix.py
similarity index 87%
rename from mathgenerator/funcs/multiplyIntToMatrix22.py
rename to mathgenerator/funcs/multiply_int_to_22_matrix.py
index 1409a5b..3d79834 100644
--- a/mathgenerator/funcs/multiplyIntToMatrix22.py
+++ b/mathgenerator/funcs/multiply_int_to_22_matrix.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100):
@@ -14,7 +13,7 @@ def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100):
return problem, solution
-intMatrix22Multiplication = Generator("Integer Multiplication with 2x2 Matrix",
+multiply_int_to_22_matrix = Generator("Integer Multiplication with 2x2 Matrix",
17, "k * [[a,b],[c,d]]=",
"[[k*a,k*b],[k*c,k*d]]",
multiplyIntToMatrix22)
diff --git a/mathgenerator/funcs/nthFibonacciNumberFunc.py b/mathgenerator/funcs/nth_fibonacci_number.py
similarity index 59%
rename from mathgenerator/funcs/nthFibonacciNumberFunc.py
rename to mathgenerator/funcs/nth_fibonacci_number.py
index 1983a0d..cfb7e8a 100644
--- a/mathgenerator/funcs/nthFibonacciNumberFunc.py
+++ b/mathgenerator/funcs/nth_fibonacci_number.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def nthFibonacciNumberFunc(maxN=100):
@@ -11,6 +10,6 @@ def nthFibonacciNumberFunc(maxN=100):
return problem, solution
-nthFibonacciNumberGen = Generator("nth Fibonacci number", 62,
- "What is the nth Fibonacci number", "Fn",
- nthFibonacciNumberFunc)
+nth_fibonacci_number = Generator("nth Fibonacci number", 62,
+ "What is the nth Fibonacci number", "Fn",
+ nthFibonacciNumberFunc)
diff --git a/mathgenerator/funcs/percentageFunc.py b/mathgenerator/funcs/percentage.py
similarity index 93%
rename from mathgenerator/funcs/percentageFunc.py
rename to mathgenerator/funcs/percentage.py
index 36d72be..e108a10 100644
--- a/mathgenerator/funcs/percentageFunc.py
+++ b/mathgenerator/funcs/percentage.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def percentageFunc(maxValue=99, maxpercentage=99):
diff --git a/mathgenerator/funcs/permutationFunc.py b/mathgenerator/funcs/permutation.py
similarity index 88%
rename from mathgenerator/funcs/permutationFunc.py
rename to mathgenerator/funcs/permutation.py
index f4764c0..63d78a8 100644
--- a/mathgenerator/funcs/permutationFunc.py
+++ b/mathgenerator/funcs/permutation.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def permutationFunc(maxlength=20):
@@ -12,7 +11,7 @@ def permutationFunc(maxlength=20):
return problem, solution
-permutations = Generator(
+permutation = Generator(
"Permutations", 42,
"Total permutations of 4 objects at a time from 10 objects is", "5040",
permutationFunc)
diff --git a/mathgenerator/funcs/powerRuleDifferentiationFunc.py b/mathgenerator/funcs/power_rule_differentiation.py
similarity index 69%
rename from mathgenerator/funcs/powerRuleDifferentiationFunc.py
rename to mathgenerator/funcs/power_rule_differentiation.py
index 6e41170..cdc8c76 100644
--- a/mathgenerator/funcs/powerRuleDifferentiationFunc.py
+++ b/mathgenerator/funcs/power_rule_differentiation.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
@@ -19,6 +18,6 @@ def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
return problem, solution
-powerRuleDifferentiation = Generator("Power Rule Differentiation", 7, "nx^m=",
- "(n*m)x^(m-1)",
- powerRuleDifferentiationFunc)
+power_rule_differentiation = Generator("Power Rule Differentiation", 7, "nx^m=",
+ "(n*m)x^(m-1)",
+ powerRuleDifferentiationFunc)
diff --git a/mathgenerator/funcs/powerRuleIntegrationFunc.py b/mathgenerator/funcs/power_rule_integration.py
similarity index 76%
rename from mathgenerator/funcs/powerRuleIntegrationFunc.py
rename to mathgenerator/funcs/power_rule_integration.py
index 4b5684b..7356a68 100644
--- a/mathgenerator/funcs/powerRuleIntegrationFunc.py
+++ b/mathgenerator/funcs/power_rule_integration.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def powerRuleIntegrationFunc(maxCoef=10, maxExp=10, maxTerms=5):
@@ -22,5 +21,5 @@ def powerRuleIntegrationFunc(maxCoef=10, maxExp=10, maxTerms=5):
return problem, solution
-powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=",
- "(n/m)x^(m+1)", powerRuleIntegrationFunc)
+power_rule_integration = Generator("Power Rule Integration", 48, "nx^m=",
+ "(n/m)x^(m+1)", powerRuleIntegrationFunc)
diff --git a/mathgenerator/funcs/primeFactorsFunc.py b/mathgenerator/funcs/prime_factors.py
similarity index 70%
rename from mathgenerator/funcs/primeFactorsFunc.py
rename to mathgenerator/funcs/prime_factors.py
index 6eed7a9..575db01 100644
--- a/mathgenerator/funcs/primeFactorsFunc.py
+++ b/mathgenerator/funcs/prime_factors.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def primeFactorsFunc(minVal=1, maxVal=200):
@@ -23,5 +22,5 @@ def primeFactorsFunc(minVal=1, maxVal=200):
return problem, solution
-primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =",
- "[b, c, d, ...]", primeFactorsFunc)
+prime_factors = Generator("Prime Factorisation", 27, "Prime Factors of a =",
+ "[b, c, d, ...]", primeFactorsFunc)
diff --git a/mathgenerator/funcs/profitLossPercentFunc.py b/mathgenerator/funcs/profit_loss_percent.py
similarity index 89%
rename from mathgenerator/funcs/profitLossPercentFunc.py
rename to mathgenerator/funcs/profit_loss_percent.py
index c9d1d4d..c43351c 100644
--- a/mathgenerator/funcs/profitLossPercentFunc.py
+++ b/mathgenerator/funcs/profit_loss_percent.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def profitLossPercentFunc(maxCP=1000, maxSP=1000):
@@ -17,7 +16,7 @@ def profitLossPercentFunc(maxCP=1000, maxSP=1000):
return problem, solution
-profitLossPercent = Generator(
+profit_loss_percent = Generator(
"Profit or Loss Percent", 63,
"Profit/ Loss percent when CP = cp and SP = sp is: ", "percent",
profitLossPercentFunc)
diff --git a/mathgenerator/funcs/pythagoreanTheoremFunc.py b/mathgenerator/funcs/pythagorean_theorem.py
similarity index 88%
rename from mathgenerator/funcs/pythagoreanTheoremFunc.py
rename to mathgenerator/funcs/pythagorean_theorem.py
index 26dc744..7387499 100644
--- a/mathgenerator/funcs/pythagoreanTheoremFunc.py
+++ b/mathgenerator/funcs/pythagorean_theorem.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def pythagoreanTheoremFunc(maxLength=20):
@@ -12,7 +11,7 @@ def pythagoreanTheoremFunc(maxLength=20):
return problem, solution
-pythagoreanTheorem = Generator(
+pythagorean_theorem = Generator(
"Pythagorean Theorem", 25,
"The hypotenuse of a right triangle given the other two lengths a and b = ",
"hypotenuse", pythagoreanTheoremFunc)
diff --git a/mathgenerator/funcs/quadraticEquation.py b/mathgenerator/funcs/quadratic_equation.py
similarity index 89%
rename from mathgenerator/funcs/quadraticEquation.py
rename to mathgenerator/funcs/quadratic_equation.py
index 021faff..5961852 100644
--- a/mathgenerator/funcs/quadraticEquation.py
+++ b/mathgenerator/funcs/quadratic_equation.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def quadraticEquation(maxVal=100):
@@ -16,7 +15,7 @@ def quadraticEquation(maxVal=100):
return problem, solution
-quadraticEquationSolve = Generator(
+quadratic_equation = Generator(
"Quadratic Equation", 50,
"Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2",
quadraticEquation)
diff --git a/mathgenerator/funcs/radianToDegFunc.py b/mathgenerator/funcs/radian_to_deg.py
similarity index 50%
rename from mathgenerator/funcs/radianToDegFunc.py
rename to mathgenerator/funcs/radian_to_deg.py
index b9c7b56..e48acc0 100644
--- a/mathgenerator/funcs/radianToDegFunc.py
+++ b/mathgenerator/funcs/radian_to_deg.py
@@ -2,7 +2,8 @@ from .__init__ import *
from numpy import pi
-def radianToDegFunc(max_rad=pi):
+def radianToDegFunc(max_rad=3):
+ # max_rad is supposed to be pi but random can't handle non-integer
a = random.randint(0, max_rad)
b = (180 * a) / pi
b = round(b, 2)
@@ -13,4 +14,5 @@ def radianToDegFunc(max_rad=pi):
return problem, solution
-radianToDeg = Generator("Radians to Degrees", 87, "Angle a in degrees is = ", "b", radianToDegFunc)
+radian_to_deg = Generator("Radians to Degrees", 87,
+ "Angle a in degrees is = ", "b", radianToDegFunc)
diff --git a/mathgenerator/funcs/sectorAreaFunc.py b/mathgenerator/funcs/sector_area.py
similarity index 68%
rename from mathgenerator/funcs/sectorAreaFunc.py
rename to mathgenerator/funcs/sector_area.py
index db9dc7e..9a14728 100644
--- a/mathgenerator/funcs/sectorAreaFunc.py
+++ b/mathgenerator/funcs/sector_area.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def sectorAreaFunc(maxRadius=49, maxAngle=359):
@@ -12,6 +11,6 @@ def sectorAreaFunc(maxRadius=49, maxAngle=359):
return problem, solution
-sectorArea = Generator("Area of a Sector", 75,
- "Area of a sector with radius, r and angle, a ", "Area",
- sectorAreaFunc)
+sector_area = Generator("Area of a Sector", 75,
+ "Area of a sector with radius, r and angle, a ", "Area",
+ sectorAreaFunc)
diff --git a/mathgenerator/funcs/simpleInterestFunc.py b/mathgenerator/funcs/simple_interest.py
similarity index 91%
rename from mathgenerator/funcs/simpleInterestFunc.py
rename to mathgenerator/funcs/simple_interest.py
index 23f1afc..00242b1 100644
--- a/mathgenerator/funcs/simpleInterestFunc.py
+++ b/mathgenerator/funcs/simple_interest.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def simpleInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
@@ -16,7 +15,7 @@ def simpleInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
return problem, solution
-simpleInterest = Generator(
+simple_interest = 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)
diff --git a/mathgenerator/funcs/squareFunc.py b/mathgenerator/funcs/square.py
similarity index 88%
rename from mathgenerator/funcs/squareFunc.py
rename to mathgenerator/funcs/square.py
index dbe284c..28ed2c3 100644
--- a/mathgenerator/funcs/squareFunc.py
+++ b/mathgenerator/funcs/square.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def squareFunc(maxSquareNum=20):
diff --git a/mathgenerator/funcs/squareRootFunc.py b/mathgenerator/funcs/square_root.py
similarity index 66%
rename from mathgenerator/funcs/squareRootFunc.py
rename to mathgenerator/funcs/square_root.py
index 6cc410a..fa09006 100644
--- a/mathgenerator/funcs/squareRootFunc.py
+++ b/mathgenerator/funcs/square_root.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def squareRootFunc(minNo=1, maxNo=12):
@@ -11,4 +10,4 @@ def squareRootFunc(minNo=1, maxNo=12):
return problem, solution
-squareRoot = Generator("Square Root", 6, "sqrt(a)=", "b", squareRootFunc)
+square_root = Generator("Square Root", 6, "sqrt(a)=", "b", squareRootFunc)
diff --git a/mathgenerator/funcs/subtractionFunc.py b/mathgenerator/funcs/subtraction.py
similarity index 91%
rename from mathgenerator/funcs/subtractionFunc.py
rename to mathgenerator/funcs/subtraction.py
index 9298037..47c7ef2 100644
--- a/mathgenerator/funcs/subtractionFunc.py
+++ b/mathgenerator/funcs/subtraction.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def subtractionFunc(maxMinuend=99, maxDiff=99):
diff --git a/mathgenerator/funcs/sumOfAnglesOfPolygonFunc.py b/mathgenerator/funcs/sum_of_polygon_angles.py
similarity index 50%
rename from mathgenerator/funcs/sumOfAnglesOfPolygonFunc.py
rename to mathgenerator/funcs/sum_of_polygon_angles.py
index c0a9d7b..29519df 100644
--- a/mathgenerator/funcs/sumOfAnglesOfPolygonFunc.py
+++ b/mathgenerator/funcs/sum_of_polygon_angles.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def sumOfAnglesOfPolygonFunc(maxSides=12):
@@ -11,6 +10,6 @@ def sumOfAnglesOfPolygonFunc(maxSides=12):
return problem, solution
-sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58,
- "Sum of angles of polygon with n sides = ",
- "sum", sumOfAnglesOfPolygonFunc)
+sum_of_polygon_angles = Generator("Sum of Angles of Polygon", 58,
+ "Sum of angles of polygon with n sides = ",
+ "sum", sumOfAnglesOfPolygonFunc)
diff --git a/mathgenerator/funcs/surdsComparisonFunc.py b/mathgenerator/funcs/surds_comparison.py
similarity index 72%
rename from mathgenerator/funcs/surdsComparisonFunc.py
rename to mathgenerator/funcs/surds_comparison.py
index 278c3c4..7c2825c 100644
--- a/mathgenerator/funcs/surdsComparisonFunc.py
+++ b/mathgenerator/funcs/surds_comparison.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def surdsComparisonFunc(maxValue=100, maxRoot=10):
@@ -18,6 +17,6 @@ def surdsComparisonFunc(maxValue=100, maxRoot=10):
return problem, solution
-surdsComparison = Generator("Comparing surds", 55,
- "Fill in the blanks a^(1/b) _ c^(1/d)", ">/=",
- surdsComparisonFunc)
+surds_comparison = Generator("Comparing surds", 55,
+ "Fill in the blanks a^(1/b) _ c^(1/d)", ">/=",
+ surdsComparisonFunc)
diff --git a/mathgenerator/funcs/surfaceAreaCone.py b/mathgenerator/funcs/surface_area_cone.py
similarity index 89%
rename from mathgenerator/funcs/surfaceAreaCone.py
rename to mathgenerator/funcs/surface_area_cone.py
index 8497460..2d86c5e 100644
--- a/mathgenerator/funcs/surfaceAreaCone.py
+++ b/mathgenerator/funcs/surface_area_cone.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):
@@ -14,7 +13,7 @@ def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):
return problem, solution
-surfaceAreaConeGen = Generator(
+surface_area_cone = Generator(
"Surface Area of cone", 38,
"Surface area of cone with height = a units and radius = b units is",
"c units^2", surfaceAreaCone)
diff --git a/mathgenerator/funcs/surfaceAreaCube.py b/mathgenerator/funcs/surface_area_cube.py
similarity index 52%
rename from mathgenerator/funcs/surfaceAreaCube.py
rename to mathgenerator/funcs/surface_area_cube.py
index 42b07f4..f2f4a99 100644
--- a/mathgenerator/funcs/surfaceAreaCube.py
+++ b/mathgenerator/funcs/surface_area_cube.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def surfaceAreaCube(maxSide=20, unit='m'):
@@ -10,6 +9,6 @@ def surfaceAreaCube(maxSide=20, unit='m'):
return problem, solution
-surfaceAreaCubeGen = Generator("Surface Area of Cube", 32,
- "Surface area of cube with side a units is",
- "b units^2", surfaceAreaCube)
+surface_area_cube = Generator("Surface Area of Cube", 32,
+ "Surface area of cube with side a units is",
+ "b units^2", surfaceAreaCube)
diff --git a/mathgenerator/funcs/surfaceAreaCuboid.py b/mathgenerator/funcs/surface_area_cuboid.py
similarity index 88%
rename from mathgenerator/funcs/surfaceAreaCuboid.py
rename to mathgenerator/funcs/surface_area_cuboid.py
index 0889441..723217c 100644
--- a/mathgenerator/funcs/surfaceAreaCuboid.py
+++ b/mathgenerator/funcs/surface_area_cuboid.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def surfaceAreaCuboid(maxSide=20, unit='m'):
@@ -13,7 +12,7 @@ def surfaceAreaCuboid(maxSide=20, unit='m'):
return problem, solution
-surfaceAreaCuboidGen = Generator(
+surface_area_cuboid = Generator(
"Surface Area of Cuboid", 33,
"Surface area of cuboid with sides = a units, b units, c units is",
"d units^2", surfaceAreaCuboid)
diff --git a/mathgenerator/funcs/surfaceAreaCylinder.py b/mathgenerator/funcs/surface_area_cylinder.py
similarity index 88%
rename from mathgenerator/funcs/surfaceAreaCylinder.py
rename to mathgenerator/funcs/surface_area_cylinder.py
index 3a7a1e8..bdbed93 100644
--- a/mathgenerator/funcs/surfaceAreaCylinder.py
+++ b/mathgenerator/funcs/surface_area_cylinder.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m'):
@@ -12,7 +11,7 @@ def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m'):
return problem, solution
-surfaceAreaCylinderGen = Generator(
+surface_area_cylinder = Generator(
"Surface Area of Cylinder", 34,
"Surface area of cylinder with height = a units and radius = b units is",
"c units^2", surfaceAreaCylinder)
diff --git a/mathgenerator/funcs/surfaceAreaSphere.py b/mathgenerator/funcs/surface_area_sphere.py
similarity index 85%
rename from mathgenerator/funcs/surfaceAreaSphere.py
rename to mathgenerator/funcs/surface_area_sphere.py
index 86a9456..bc5e91a 100644
--- a/mathgenerator/funcs/surfaceAreaSphere.py
+++ b/mathgenerator/funcs/surface_area_sphere.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def surfaceAreaSphere(maxSide=20, unit='m'):
@@ -11,7 +10,7 @@ def surfaceAreaSphere(maxSide=20, unit='m'):
return problem, solution
-surfaceAreaSphereGen = Generator(
+surface_area_sphere = Generator(
"Surface Area of Sphere", 60,
"Surface area of sphere with radius = a units is", "d units^2",
surfaceAreaSphere)
diff --git a/mathgenerator/funcs/systemOfEquationsFunc.py b/mathgenerator/funcs/system_of_equations.py
similarity index 89%
rename from mathgenerator/funcs/systemOfEquationsFunc.py
rename to mathgenerator/funcs/system_of_equations.py
index ef00b0e..c35e549 100644
--- a/mathgenerator/funcs/systemOfEquationsFunc.py
+++ b/mathgenerator/funcs/system_of_equations.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def systemOfEquationsFunc(range_x=10, range_y=10, coeff_mult_range=10):
@@ -48,6 +47,6 @@ def systemOfEquationsFunc(range_x=10, range_y=10, coeff_mult_range=10):
# 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)
+system_of_equations = Generator("Solve a System of Equations in R^2", 23,
+ "2x + 5y = 13, -3x - 3y = -6", "x = -1, y = 3",
+ systemOfEquationsFunc)
diff --git a/mathgenerator/funcs/thirdAngleOfTriangleFunc.py b/mathgenerator/funcs/third_angle_of_triangle.py
similarity index 57%
rename from mathgenerator/funcs/thirdAngleOfTriangleFunc.py
rename to mathgenerator/funcs/third_angle_of_triangle.py
index f5f7afb..b41ff35 100644
--- a/mathgenerator/funcs/thirdAngleOfTriangleFunc.py
+++ b/mathgenerator/funcs/third_angle_of_triangle.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def thirdAngleOfTriangleFunc(maxAngle=89):
@@ -12,6 +11,6 @@ def thirdAngleOfTriangleFunc(maxAngle=89):
return problem, solution
-thirdAngleOfTriangle = Generator("Third Angle of Triangle", 22,
- "Third Angle of the triangle = ", "angle3",
- thirdAngleOfTriangleFunc)
+third_angle_of_triangle = Generator("Third Angle of Triangle", 22,
+ "Third Angle of the triangle = ", "angle3",
+ thirdAngleOfTriangleFunc)
diff --git a/mathgenerator/funcs/isTriangleValidFunc.py b/mathgenerator/funcs/valid_triangle.py
similarity index 72%
rename from mathgenerator/funcs/isTriangleValidFunc.py
rename to mathgenerator/funcs/valid_triangle.py
index 19a4240..e8a5128 100644
--- a/mathgenerator/funcs/isTriangleValidFunc.py
+++ b/mathgenerator/funcs/valid_triangle.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def isTriangleValidFunc(maxSideLength=50):
@@ -21,6 +20,6 @@ def isTriangleValidFunc(maxSideLength=50):
return problem, solution
-doesTriangleExist = Generator("Triangle exists check", 19,
- "Does triangle with sides a, b and c exist?",
- "Yes/No", isTriangleValidFunc)
+valid_triangle = Generator("Triangle exists check", 19,
+ "Does triangle with sides a, b and c exist?",
+ "Yes/No", isTriangleValidFunc)
diff --git a/mathgenerator/funcs/vectorCrossFunc.py b/mathgenerator/funcs/vector_cross.py
similarity index 72%
rename from mathgenerator/funcs/vectorCrossFunc.py
rename to mathgenerator/funcs/vector_cross.py
index 318beec..92b82a9 100644
--- a/mathgenerator/funcs/vectorCrossFunc.py
+++ b/mathgenerator/funcs/vector_cross.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def vectorCrossFunc(minVal=-20, maxVal=20):
@@ -15,5 +14,5 @@ def vectorCrossFunc(minVal=-20, maxVal=20):
return problem, solution
-vectorCross = Generator("Cross Product of 2 Vectors", 43, "a X b = ", "c",
- vectorCrossFunc)
+vector_cross = Generator("Cross Product of 2 Vectors", 43, "a X b = ", "c",
+ vectorCrossFunc)
diff --git a/mathgenerator/funcs/vectorDotFunc.py b/mathgenerator/funcs/vector_dot.py
similarity index 70%
rename from mathgenerator/funcs/vectorDotFunc.py
rename to mathgenerator/funcs/vector_dot.py
index 0ca2609..608ce66 100644
--- a/mathgenerator/funcs/vectorDotFunc.py
+++ b/mathgenerator/funcs/vector_dot.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def vectorDotFunc(minVal=-20, maxVal=20):
@@ -12,5 +11,5 @@ def vectorDotFunc(minVal=-20, maxVal=20):
return problem, solution
-vectorDot = Generator("Dot Product of 2 Vectors", 72, "a . b = ", "c",
- vectorDotFunc)
+vector_dot = Generator("Dot Product of 2 Vectors", 72, "a . b = ", "c",
+ vectorDotFunc)
diff --git a/mathgenerator/funcs/volumeCone.py b/mathgenerator/funcs/volume_cone.py
similarity index 88%
rename from mathgenerator/funcs/volumeCone.py
rename to mathgenerator/funcs/volume_cone.py
index 85dbd55..39a3a26 100644
--- a/mathgenerator/funcs/volumeCone.py
+++ b/mathgenerator/funcs/volume_cone.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def volumeCone(maxRadius=20, maxHeight=50, unit='m'):
@@ -12,7 +11,7 @@ def volumeCone(maxRadius=20, maxHeight=50, unit='m'):
return problem, solution
-volumeConeGen = Generator(
+volume_cone = Generator(
"Volume of cone", 39,
"Volume of cone with height = a units and radius = b units is",
"c units^3", volumeCone)
diff --git a/mathgenerator/funcs/volumeCube.py b/mathgenerator/funcs/volume_cube.py
similarity index 55%
rename from mathgenerator/funcs/volumeCube.py
rename to mathgenerator/funcs/volume_cube.py
index ff1ac76..1de5984 100644
--- a/mathgenerator/funcs/volumeCube.py
+++ b/mathgenerator/funcs/volume_cube.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def volumeCube(maxSide=20, unit='m'):
@@ -11,6 +10,6 @@ def volumeCube(maxSide=20, unit='m'):
return problem, solution
-volumeCubeGen = Generator("Volum of Cube", 35,
- "Volume of cube with side a units is", "b units^3",
- volumeCube)
+volume_cube = Generator("Volum of Cube", 35,
+ "Volume of cube with side a units is", "b units^3",
+ volumeCube)
diff --git a/mathgenerator/funcs/volumeCuboid.py b/mathgenerator/funcs/volume_cuboid.py
similarity index 88%
rename from mathgenerator/funcs/volumeCuboid.py
rename to mathgenerator/funcs/volume_cuboid.py
index d25d753..a1eee6f 100644
--- a/mathgenerator/funcs/volumeCuboid.py
+++ b/mathgenerator/funcs/volume_cuboid.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def volumeCuboid(maxSide=20, unit='m'):
@@ -13,7 +12,7 @@ def volumeCuboid(maxSide=20, unit='m'):
return problem, solution
-volumeCuboidGen = Generator(
+volume_cuboid = Generator(
"Volume of Cuboid", 36,
"Volume of cuboid with sides = a units, b units, c units is", "d units^3",
volumeCuboid)
diff --git a/mathgenerator/funcs/volumeCylinder.py b/mathgenerator/funcs/volume_cylinder.py
similarity index 88%
rename from mathgenerator/funcs/volumeCylinder.py
rename to mathgenerator/funcs/volume_cylinder.py
index e021aab..28b89a1 100644
--- a/mathgenerator/funcs/volumeCylinder.py
+++ b/mathgenerator/funcs/volume_cylinder.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def volumeCylinder(maxRadius=20, maxHeight=50, unit='m'):
@@ -12,7 +11,7 @@ def volumeCylinder(maxRadius=20, maxHeight=50, unit='m'):
return problem, solution
-volumeCylinderGen = Generator(
+volume_cylinder = Generator(
"Volume of cylinder", 37,
"Volume of cylinder with height = a units and radius = b units is",
"c units^3", volumeCylinder)
diff --git a/mathgenerator/funcs/volumeSphereFunc.py b/mathgenerator/funcs/volume_sphere.py
similarity index 55%
rename from mathgenerator/funcs/volumeSphereFunc.py
rename to mathgenerator/funcs/volume_sphere.py
index 038607e..b686bd4 100644
--- a/mathgenerator/funcs/volumeSphereFunc.py
+++ b/mathgenerator/funcs/volume_sphere.py
@@ -1,5 +1,4 @@
from .__init__ import *
-from ..__init__ import Generator
def volumeSphereFunc(maxRadius=100):
@@ -11,6 +10,6 @@ def volumeSphereFunc(maxRadius=100):
return problem, solution
-volumeSphere = Generator("Volume of Sphere", 61,
- "Volume of sphere with radius r m = ",
- "(4*pi/3)*r*r*r", volumeSphereFunc)
+volume_sphere = Generator("Volume of Sphere", 61,
+ "Volume of sphere with radius r m = ",
+ "(4*pi/3)*r*r*r", volumeSphereFunc)
diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py
index 389f8dd..2a969fa 100644
--- a/mathgenerator/mathgen.py
+++ b/mathgenerator/mathgen.py
@@ -1,280 +1,11 @@
-import random
-import math
-import fractions
from .funcs import *
from .__init__ import getGenList
+
genList = getGenList()
-# || Generator class
-
-
-class Generator:
- def __init__(self, title, id, generalProb, generalSol, func):
- self.title = title
- self.id = id
- self.generalProb = generalProb
- self.generalSol = generalSol
- self.func = func
- genList.append([id, title, self])
-
- def __str__(self):
- return str(
- self.id
- ) + " " + self.title + " " + self.generalProb + " " + self.generalSol
-
- def __call__(self, *args, **kwargs):
- return self.func(*args, **kwargs)
-
# || Non-generator Functions
def genById(id):
generator = genList[id][2]
return (generator())
-
-
-# Format is:
-# = Generator("", , , , )
-
-# Funcs_start - DO NOT REMOVE!
-# addition = Generator("Addition", 0, "a+b=", "c", additionFunc)
-subtraction = Generator("Subtraction", 1, "a-b=", "c", subtractionFunc)
-multiplication = Generator("Multiplication", 2, "a*b=", "c",
- multiplicationFunc)
-division = Generator("Division", 3, "a/b=", "c", divisionFunc)
-binaryComplement1s = Generator("Binary Complement 1s", 4, "1010=", "0101",
- binaryComplement1sFunc)
-moduloDivision = Generator("Modulo Division", 5, "a%b=", "c", moduloFunc)
-squareRoot = Generator("Square Root", 6, "sqrt(a)=", "b", squareRootFunc)
-powerRuleDifferentiation = Generator("Power Rule Differentiation", 7, "nx^m=",
- "(n*m)x^(m-1)",
- powerRuleDifferentiationFunc)
-square = Generator("Square", 8, "a^2", "b", squareFunc)
-lcm = Generator("LCM (Least Common Multiple)", 9, "LCM of a and b = ", "c",
- lcmFunc)
-gcd = Generator("GCD (Greatest Common Denominator)", 10, "GCD of a and b = ",
- "c", gcdFunc)
-basicAlgebra = Generator("Basic Algebra", 11, "ax + b = c", "d",
- basicAlgebraFunc)
-log = Generator("Logarithm", 12, "log2(8)", "3", logFunc)
-intDivision = Generator("Easy Division", 13, "a/b=", "c", divisionToIntFunc)
-decimalToBinary = Generator("Decimal to Binary", 14, "Binary of a=", "b",
- DecimalToBinaryFunc)
-binaryToDecimal = Generator("Binary to Decimal", 15, "Decimal of a=", "b",
- BinaryToDecimalFunc)
-fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y",
- divideFractionsFunc)
-intMatrix22Multiplication = Generator("Integer Multiplication with 2x2 Matrix",
- 17, "k * [[a,b],[c,d]]=",
- "[[k*a,k*b],[k*c,k*d]]",
- multiplyIntToMatrix22)
-areaOfTriangle = Generator("Area of Triangle", 18,
- "Area of Triangle with side lengths a, b, c = ",
- "area", areaOfTriangleFunc)
-doesTriangleExist = Generator("Triangle exists check", 19,
- "Does triangle with sides a, b and c exist?",
- "Yes/No", isTriangleValidFunc)
-midPointOfTwoPoint = Generator("Midpoint of the two point", 20,
- "((X1,Y1),(X2,Y2))=", "((X1+X2)/2,(Y1+Y2)/2)",
- MidPointOfTwoPointFunc)
-factoring = Generator("Factoring Quadratic", 21, "x^2+(x1+x2)+x1*x2",
- "(x-x1)(x-x2)", factoringFunc)
-thirdAngleOfTriangle = Generator("Third Angle of Triangle", 22,
- "Third Angle of the triangle = ", "angle3",
- thirdAngleOfTriangleFunc)
-systemOfEquations = Generator("Solve a System of Equations in R^2", 23,
- "2x + 5y = 13, -3x - 3y = -6", "x = -1, y = 3",
- systemOfEquationsFunc)
-distance2Point = Generator("Distance between 2 points", 24,
- "Find the distance between (x1,y1) and (x2,y2)",
- "sqrt(distanceSquared)", distanceTwoPointsFunc)
-pythagoreanTheorem = Generator(
- "Pythagorean Theorem", 25,
- "The hypotenuse of a right triangle given the other two lengths a and b = ",
- "hypotenuse", pythagoreanTheoremFunc)
-# This has multiple variables whereas #23 has only x and y
-linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12",
- "x=-20 & y=12", linearEquationsFunc)
-primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =",
- "[b, c, d, ...]", primeFactorsFunc)
-fractionMultiplication = Generator("Fraction Multiplication", 28,
- "(a/b)*(c/d)=", "x/y",
- multiplyFractionsFunc)
-angleRegularPolygon = Generator(
- "Angle of a Regular Polygon", 29,
- "Find the angle of a regular polygon with 6 sides", "120",
- regularPolygonAngleFunc)
-combinations = Generator(
- "Combinations of Objects", 30,
- "Combinations available for picking 4 objects at a time from 6 distinct objects =",
- " 15", combinationsFunc)
-factorial = Generator("Factorial", 31, "a! = ", "b", factorialFunc)
-
-surfaceAreaCubeGen = Generator("Surface Area of Cube", 32,
- "Surface area of cube with side a units is",
- "b units^2", surfaceAreaCube)
-surfaceAreaCuboidGen = Generator(
- "Surface Area of Cuboid", 33,
- "Surface area of cuboid with sides = a units, b units, c units is",
- "d units^2", surfaceAreaCuboid)
-surfaceAreaCylinderGen = Generator(
- "Surface Area of Cylinder", 34,
- "Surface area of cylinder with height = a units and radius = b units is",
- "c units^2", surfaceAreaCylinder)
-volumeCubeGen = Generator("Volum of Cube", 35,
- "Volume of cube with side a units is", "b units^3",
- volumeCube)
-volumeCuboidGen = Generator(
- "Volume of Cuboid", 36,
- "Volume of cuboid with sides = a units, b units, c units is", "d units^3",
- volumeCuboid)
-volumeCylinderGen = Generator(
- "Volume of cylinder", 37,
- "Volume of cylinder with height = a units and radius = b units is",
- "c units^3", volumeCylinder)
-surfaceAreaConeGen = Generator(
- "Surface Area of cone", 38,
- "Surface area of cone with height = a units and radius = b units is",
- "c units^2", surfaceAreaCone)
-volumeConeGen = Generator(
- "Volume of cone", 39,
- "Volume of cone with height = a units and radius = b units is",
- "c units^3", volumeCone)
-commonFactors = Generator("Common Factors", 40,
- "Common Factors of {a} and {b} = ", "[c, d, ...]",
- commonFactorsFunc)
-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)
-permutations = Generator(
- "Permutations", 42,
- "Total permutations of 4 objects at a time from 10 objects is", "5040",
- permutationFunc)
-vectorCross = Generator("Cross Product of 2 Vectors", 43, "a X b = ", "c",
- vectorCrossFunc)
-compareFractions = Generator(
- "Compare Fractions", 44,
- "Which symbol represents the comparison between a/b and c/d?", ">/=",
- compareFractionsFunc)
-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)
-matrixMultiplication = Generator("Multiplication of two matrices", 46,
- "Multiply two matrices A and B", "C",
- matrixMultiplicationFunc)
-CubeRoot = Generator("Cube Root", 47, "Cuberoot of a upto 2 decimal places is",
- "b", cubeRootFunc)
-powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=",
- "(n/m)x^(m+1)", powerRuleIntegrationFunc)
-fourthAngleOfQuadrilateral = Generator(
- "Fourth Angle of Quadrilateral", 49,
- "Fourth angle of Quadrilateral with angles a,b,c =", "angle4",
- fourthAngleOfQuadriFunc)
-quadraticEquationSolve = Generator(
- "Quadratic Equation", 50,
- "Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2",
- quadraticEquation)
-hcf = Generator("HCF (Highest Common Factor)", 51, "HCF of a and b = ", "c",
- hcfFunc)
-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)
-exponentiation = Generator("Exponentiation", 53, "a^b = ", "c",
- exponentiationFunc)
-confidenceInterval = Generator("Confidence interval For sample S", 54,
- "With X% confidence", "is (A,B)",
- confidenceIntervalFunc)
-surdsComparison = Generator("Comparing surds", 55,
- "Fill in the blanks a^(1/b) _ c^(1/d)", ">/=",
- surdsComparisonFunc)
-fibonacciSeries = Generator(
- "Fibonacci Series", 56, "fibonacci series of first a numbers",
- "prints the fibonacci series starting from 0 to a", fibonacciSeriesFunc)
-basicTrigonometry = Generator("Trigonometric Values", 57, "What is sin(X)?",
- "ans", basicTrigonometryFunc)
-sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58,
- "Sum of angles of polygon with n sides = ",
- "sum", sumOfAnglesOfPolygonFunc)
-dataSummary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c",
- "Mean:a+b+c/3,Std,Var", dataSummaryFunc)
-surfaceAreaSphereGen = Generator(
- "Surface Area of Sphere", 60,
- "Surface area of sphere with radius = a units is", "d units^2",
- surfaceAreaSphere)
-volumeSphere = Generator("Volume of Sphere", 61,
- "Volume of sphere with radius r m = ",
- "(4*pi/3)*r*r*r", volumeSphereFunc)
-nthFibonacciNumberGen = Generator("nth Fibonacci number", 62,
- "What is the nth Fibonacci number", "Fn",
- nthFibonacciNumberFunc)
-profitLossPercent = Generator(
- "Profit or Loss Percent", 63,
- "Profit/ Loss percent when CP = cp and SP = sp is: ", "percent",
- profitLossPercentFunc)
-binaryToHex = Generator("Binary to Hexidecimal", 64, "Hexidecimal of a=", "b",
- binaryToHexFunc)
-complexNumMultiply = Generator("Multiplication of 2 complex numbers", 65,
- "(x + j) (y + j) = ", "xy + xj + yj -1",
- multiplyComplexNumbersFunc)
-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)
-geometricMean = Generator("Geometric Mean of N Numbers", 67,
- "Geometric mean of n numbers A1 , A2 , ... , An = ",
- "(A1*A2*...An)^(1/n) = ans", geometricMeanFunc)
-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)
-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)
-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)
-absoluteDifference = Generator(
- "Absolute difference between two numbers", 71,
- "Absolute difference betweeen two numbers a and b =", "|a-b|",
- absoluteDifferenceFunc)
-vectorDot = Generator("Dot Product of 2 Vectors", 72, "a . b = ", "c",
- vectorDotFunc)
-binary2sComplement = Generator("Binary 2's Complement", 73,
- "2's complement of 11010110 =", "101010",
- binary2sComplementFunc)
-invertmatrix = Generator("Inverse of a Matrix", 74, "Inverse of a matrix A is",
- "A^(-1)", matrixInversion)
-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)
-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)
-
-setoperations = Generator("Union,Intersection,Difference of Two Sets", 84,
- "Union,intersection,difference",
- "aUb,a^b,a-b,b-a,", set_operation)
diff --git a/setup.py b/setup.py
index 4bfbcd0..7b022b4 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,16 @@
from setuptools import setup, find_packages
setup(name='mathgenerator',
- version='1.1.3',
+ version='1.1.4',
description='An open source solution for generating math problems',
url='https://github.com/todarith/mathgenerator',
author='Luke Weiler',
author_email='lukew25073@gmail.com',
license='MIT',
packages=find_packages(),
- install_requires=[],
+ install_requires=[
+ 'sympy',
+ 'numpy',
+ 'scipy'
+ ],
entry_points={})
diff --git a/test.py b/test.py
index 88a2724..07b6b87 100644
--- a/test.py
+++ b/test.py
@@ -3,10 +3,11 @@ from mathgenerator import mathgen
# test your generators here
print(mathgen.addition())
-print(mathgen.genById(79))
# prints each generator in genList
-
list = mathgen.getGenList()
for item in list:
print(item[2])
+
+# print(mathgen.getGenList())
+print(mathgen.genById(92))
diff --git a/tests/test_mathgen.py b/tests/test_mathgen.py
index ed9066b..745b9dc 100644
--- a/tests/test_mathgen.py
+++ b/tests/test_mathgen.py
@@ -33,15 +33,15 @@ def test_division(maxRes, maxDivid):
@given(maxRes=st.integers(min_value=1), maxModulo=st.integers(min_value=1))
-def test_moduloDivision(maxRes, maxModulo):
+def test_modulo_division(maxRes, maxModulo):
assume(maxRes > maxModulo)
- problem, solution = moduloDivision.func(maxRes, maxModulo)
+ problem, solution = modulo_division.func(maxRes, maxModulo)
assert eval(problem[:-1]) == int(solution)
@given(minNo=st.integers(min_value=1),
maxNo=st.integers(min_value=1, max_value=2**50))
-def test_squareRoot(minNo, maxNo):
+def test_square_root(minNo, maxNo):
assume(maxNo > minNo)
- problem, solution = squareRoot.func(minNo, maxNo)
+ problem, solution = square_root.func(minNo, maxNo)
assert eval(problem[:-1]) == float(solution)
|