mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
48
README.md
48
README.md
@@ -1,37 +1,47 @@
|
|||||||
# mathgenerator
|
# mathgenerator
|
||||||
|
|
||||||
A math problem generator, created for the purpose of giving self-studying students and teaching organizations the means to easily get access to random math problems to suit their needs.
|
A math problem generator, created for the purpose of giving self-studying students and teaching organizations the means to easily get access to random math problems to suit their needs.
|
||||||
|
|
||||||
To try out generators, go to https://todarith.ml/generate/
|
To try out generators, go to <https://todarith.ml/generate/>
|
||||||
|
|
||||||
If you have an idea for a generator, please add it as an issue and tag it with the "New Generator" label.
|
If you have an idea for a generator, please add it as an issue and tag it with the "New Generator" label.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The project can be install via pip
|
The project can be install via pip
|
||||||
```
|
|
||||||
|
```bash
|
||||||
pip install mathgenerator
|
pip install mathgenerator
|
||||||
```
|
```
|
||||||
|
|
||||||
Here is an example of how you would generate an addition problem:
|
Here is an example of how you would generate an addition problem:
|
||||||
```
|
|
||||||
|
```python
|
||||||
from mathgenerator import mathgen
|
from mathgenerator import mathgen
|
||||||
|
|
||||||
#generate an addition problem
|
#generate an addition problem
|
||||||
problem, solution = mathgen.addition()
|
problem, solution = mathgen.addition()
|
||||||
```
|
```
|
||||||
|
|
||||||
## List of Generators
|
## List of Generators
|
||||||
|
|
||||||
| Id | Skill | Example problem | Example Solution | Function Name |
|
| Id | Skill | Example problem | Example Solution | Function Name |
|
||||||
|------|-----------------------------------|--------------------|-------------------|--------------------------|
|
|------|-----------------------------------|--------------------|-----------------------|--------------------------|
|
||||||
| 0 | Addition | 1+5= | 6 | addition |
|
| 0 | Addition | 1+5= | 6 | addition |
|
||||||
| 1 | Subtraction | 9-4= | 5 | subtraction |
|
| 1 | Subtraction | 9-4= | 5 | subtraction |
|
||||||
| 2 | Multiplication | 4*6= | 24 | multiplication |
|
| 2 | Multiplication | 4*6= | 24 | multiplication |
|
||||||
| 3 | Division | 4/3= | 1.33333333 | division |
|
| 3 | Division | 4/3= | 1.33333333 | division |
|
||||||
| 4 | Binary Complement 1s | 1010= | 0101 | binaryComplement1s |
|
| 4 | Binary Complement 1s | 1010= | 0101 | binaryComplement1s |
|
||||||
| 5 | Modulo Division | 10%3= | 1 | moduloDivision |
|
| 5 | Modulo Division | 10%3= | 1 | moduloDivision |
|
||||||
| 6 | Square Root | sqrt(25)= | 5 | squareRootFunction |
|
| 6 | Square Root | sqrt(25)= | 5 | squareRootFunction |
|
||||||
| 7 | Power Rule Differentiation | 4x^3 | 12x^2 | powerRuleDifferentiation |
|
| 7 | Power Rule Differentiation | 4x^3 | 12x^2 | powerRuleDifferentiation |
|
||||||
| 8 | Square | 4^2 | 16 | square |
|
| 8 | Square | 4^2 | 16 | square |
|
||||||
| 9 | LCM (Least Common Multiple) | LCM of 14 and 9 = | 126 | lcm |
|
| 9 | LCM (Least Common Multiple) | LCM of 14 and 9 = | 126 | lcm |
|
||||||
| 10 | GCD (Greatest Common Denominator) | GCD of 18 and 18 = | 18 | gcd |
|
| 10 | GCD (Greatest Common Denominator) | GCD of 18 and 18 = | 18 | gcd |
|
||||||
| 11 | Basic Algebra | 9x + 7 = 10 | 1/3 | basicAlgebra |
|
| 11 | Basic Algebra | 9x + 7 = 10 | 1/3 | basicAlgebra |
|
||||||
| 12 | Logarithm | log3(3) | 1 | log |
|
| 12 | Logarithm | log3(3) | 1 | log |
|
||||||
| 13 | Easy Division | 270/15 = | 18 | intDivision |
|
| 13 | Easy Division | 270/15 = | 18 | intDivision |
|
||||||
|
| 14 | Decimal to Binary | Binary of a= | b | decimalToBinary |
|
||||||
|
| 15 | Binary to Decimal | Decimal of a= | b | binaryToDecimal |
|
||||||
|
| 16 | Fraction Division | (a/b)/(c/d)= | x/y | fractionDivision |
|
||||||
|
| 17 | Int 2x2 Matrix Multiplication | k * [[a,b],[c,d]]= | [[k*a,k*b],[k*c,k*d]] | intMatrix22Multiplication|
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
|||||||
c = random.randint(1, maxC)
|
c = random.randint(1, maxC)
|
||||||
s = (a+b+c)/2
|
s = (a+b+c)/2
|
||||||
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
|
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
|
||||||
problem = "Area of triangle with side lengths: "+ str(a) +" "+ str(b) +" "+ str(c) " = "
|
problem = "Area of triangle with side lengths: "+ str(a) +" "+ str(b) +" "+ str(c) + " = "
|
||||||
solution = area
|
solution = area
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
@@ -239,6 +239,43 @@ def isTriangleValidFunc(maxSideLength = 50):
|
|||||||
return problem, solution
|
return problem, solution
|
||||||
solution = "No"
|
solution = "No"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
def MidPointOfTwoPointFunc(maxValue=20):
|
||||||
|
x1=random.randint(-20,maxValue)
|
||||||
|
y1=random.randint(-20,maxValue)
|
||||||
|
x2=random.randint(-20,maxValue)
|
||||||
|
y2=random.randint(-20,maxValue)
|
||||||
|
problem=f"({x1},{y1}),({x2},{y2})="
|
||||||
|
solution=f"({(x1+x2)/2},{(y1+y2)/2})"
|
||||||
|
return problem,solution
|
||||||
|
|
||||||
|
def factoringFunc(range_x1 = 10, range_x2 = 10):
|
||||||
|
x1 = random.randint(-range_x1, range_x1)
|
||||||
|
x2 = random.randint(-range_x2, range_x2)
|
||||||
|
def intParser(z):
|
||||||
|
if (z == 0):
|
||||||
|
return ""
|
||||||
|
if (z > 0):
|
||||||
|
return "+" + str(z)
|
||||||
|
if (z < 0):
|
||||||
|
return "-" + str(abs(z))
|
||||||
|
|
||||||
|
b = intParser(x1 + x2)
|
||||||
|
c = intParser(x1 * x2)
|
||||||
|
|
||||||
|
if (b == "+1"):
|
||||||
|
b = "+"
|
||||||
|
|
||||||
|
if (b == ""):
|
||||||
|
problem = f"x^2{c}"
|
||||||
|
else:
|
||||||
|
problem = f"x^2{b}x{c}"
|
||||||
|
|
||||||
|
x1 = intParser(x1)
|
||||||
|
x2 = intParser(x2)
|
||||||
|
solution = f"(x{x1})(x{x2})"
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
# || Class Instances
|
# || Class Instances
|
||||||
|
|
||||||
#Format is:
|
#Format is:
|
||||||
@@ -263,3 +300,5 @@ fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y", div
|
|||||||
intMatrix22Multiplication = Generator("Integer Multiplication with 2x2 Matrix", 17, "k * [[a,b],[c,d]]=", "[[k*a,k*b],[k*c,k*d]]", multiplyIntToMatrix22)
|
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)
|
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)
|
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("Subtraction", 21, "x^2+(x1+x2)+x1*x2", "(x-x1)(x-x2)", factoringFunc)
|
||||||
Reference in New Issue
Block a user