mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Merge branch 'master' into helplessThor-definite-integral
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -2,92 +2,95 @@ 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 .definiteIntegralFunc import *
|
||||
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def additionFunc(maxSum=99, maxAddend=50):
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def combinationsFunc(maxlength=20):
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def compoundInterestFunc(maxPrinciple=10000,
|
||||
@@ -19,7 +18,7 @@ def compoundInterestFunc(maxPrinciple=10000,
|
||||
return problem, solution
|
||||
|
||||
|
||||
compoundInterest = Generator(
|
||||
compound_interest = Generator(
|
||||
"Compound Interest", 78,
|
||||
"Compound interest for a principle amount of p dollars, r% rate of interest and for a time period of t years with n times compounded annually is = ",
|
||||
"A dollars", compoundInterestFunc)
|
||||
@@ -1,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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -8,4 +8,5 @@ def decimalToOctalFunc(maxDecimal=4096):
|
||||
return problem, solution
|
||||
|
||||
|
||||
decimalToOctal = Generator("Converts decimal to octal", 82, "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)
|
||||
@@ -25,4 +25,5 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000):
|
||||
return problem, solution
|
||||
|
||||
|
||||
decimalToRomanNumerals = Generator("Converts decimal to Roman Numerals", 83, "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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
53
mathgenerator/funcs/differentiation.py
Normal file
53
mathgenerator/funcs/differentiation.py
Normal file
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def divisionFunc(maxRes=99, maxDivid=99):
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def exponentiationFunc(maxBase=20, maxExpo=10):
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def factorialFunc(maxInput=6):
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def factoringFunc(range_x1=10, range_x2=10):
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def gcdFunc(maxVal=20):
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def hcfFunc(maxVal=20):
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def lcmFunc(maxVal=20):
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def logFunc(maxBase=3, maxVal=8):
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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) + "="
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def percentageFunc(maxValue=99, maxpercentage=99):
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -2,7 +2,8 @@ from .__init__ import *
|
||||
from numpy import pi
|
||||
|
||||
|
||||
def degreeToRadFunc(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 degreeToRadFunc(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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def squareFunc(maxSquareNum=20):
|
||||
@@ -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)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .__init__ import *
|
||||
from ..__init__ import Generator
|
||||
|
||||
|
||||
def subtractionFunc(maxMinuend=99, maxDiff=99):
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -7,32 +7,8 @@ import scipy
|
||||
|
||||
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:
|
||||
# <title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>)
|
||||
|
||||
Reference in New Issue
Block a user