From ee819bc1331afa36576c57845bca3d390a2b3614 Mon Sep 17 00:00:00 2001 From: lukew3 Date: Mon, 5 Oct 2020 10:48:16 -0400 Subject: [PATCH 01/14] Addition, subtraction and initial setup --- CONTRIBUTING.md | 40 ++++++++++++++++++++++++++++++++++++++ README.md | 14 +++++++++++++ mathGenerator/__init__.py | 0 mathGenerator/generator.py | 37 +++++++++++++++++++++++++++++++++++ setup.cfg | 3 +++ setup.py | 20 +++++++++++++++++++ 6 files changed, 114 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 mathGenerator/__init__.py create mode 100644 mathGenerator/generator.py create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9c81e82 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,40 @@ +# Contributing + +This project was created with contributions at it's core. We need your help to expand the reach of this project and open-source the generation of math problems. + +## How You Can Help + +### Coding Generators +As of right now, all of our generators are being coded in python. Each generator should be contained in a function. Your function should look something like the following: +``` +def addition(maxSum, maxAddend): + """ + DESCRIPTION: + Generates addition problems with positive addends less than maxAddend and sum less than maxSum + SKILLID: + 2 + PROBLEM: + "a+b=" + SOLUTION: + "c" + """ + a = random.randint(0, maxAddend) + b = random.randint(0, min((maxSum-a), maxAddend)) #The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well + c = a+b + problem = str(a) + "+" + str(b) + "=" + solution = str(c) + return problem, solution +``` +Before coding, please check README.md to see if someone has already created the generator you plan to make. +Skillid is determined by the next available id as can be determined in the table. + +### Provide Ideas +If you have an idea for a generator but don't have the time or know-how to create it, you can add it as an issue. If you have a lot of ideas, I would suggest adding them to the table in README.md so that they are easier for our team to manage. + +## First Time Contributors +If you have never contributed to open source before here is a quick explanation of how to contribute. + +* Fork this repository on Github. This creates a copy of the current code that you can edit and make changes to. +* Navigate to your fork and make your changes. This could be done by cloning and making changes locally on your computer. You can find many tutorials on this online. You could also edit directly on github if you don't have access to a text editor but doing this, you will not be able to test your function. +* Create a pull request. Navigate to (the math generator repository pull request tab)[https://github.com/Todarith/mathGenerator/pulls] and click New Pull Request. Then click compare accross forks. Select your fork and branch as the head branch and leave a description. Then click Create Pull Request. +* If all goes well, your request will be approved and your generator added. Congratulations! diff --git a/README.md b/README.md index 58d756c..b0b708f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # 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. + +To try out generators, go to todarith.ml/generate + +## List of Generators + +| Skill | Id | Difficulty | Current Status | Contributors | Example problem | Example Solution | +|----------------------------|------|---------------|----------------|--------------|-----------------|-------------------| +| Addition | 2 | Low | Complete | @lukew3 | 1+5= | 6 | +| Subtraction | 3 | Low | Complete | @lukew3 | 9-4= | 5 | +| Multiplication | 4 | Low | In Progress | @lukew3 | 4*6= | 24 | +| Division | 5 | Low | In Progress | @lukew3 | 4/2= | 2 | + +| Factoring | - | Medium | Not Started | - | x^2+x-6 | (x-2)(x+3) | +| Power Rule Differentiation | - | Medium | Not Started | - | x^5 | 5x^4 | diff --git a/mathGenerator/__init__.py b/mathGenerator/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mathGenerator/generator.py b/mathGenerator/generator.py new file mode 100644 index 0000000..9613219 --- /dev/null +++ b/mathGenerator/generator.py @@ -0,0 +1,37 @@ +import random + +def addition(maxSum, maxAddend): + """ + DESCRIPTION: + Generates addition problems with positive addends less than maxAddend and sum less than maxSum + SKILLID: + 2 + PROBLEM: + "a+b=" + SOLUTION: + "c" + """ + a = random.randint(0, maxAddend) + b = random.randint(0, min((maxSum-a), maxAddend)) #The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well + c = a+b + problem = str(a) + "+" + str(b) + "=" + solution = str(c) + return problem, solution + +def subtraction(maxDiff, maxMinuend): + """ + DESCRIPTION: + Generates subtraction problems with difference between 0 and maxDiff. Minuend and subtrahend are between 0 and maxMinuend. + SKILLID: + 3 + PROBLEM: + "a-b=" + SOLUTION: + "c" + """ + a = random.randint(0, maxMinuend) + b = random.randint(max(0, (a-maxDiff)), a) + c = a-b + problem = str(a) + "-" + str(b) + "=" + solution = str(c) + return problem, solution diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..3287428 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +# Inside of setup.cfg +[metadata] +description-file = README.md diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b1f5269 --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +from setuptools import setup, find_packages + +setup( + name='mathGenerator', + version='1.0.0', + 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=[ + + ], + entry_points={ + 'console_scripts': [ + 'mathGenerator=mathGenerator.mainGen:main' + ], + }, +) From c496bf814695db53f08b3d958f383d6303e31134 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Mon, 5 Oct 2020 10:48:54 -0400 Subject: [PATCH 02/14] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b0b708f..65bdf2b 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,5 @@ To try out generators, go to todarith.ml/generate | Subtraction | 3 | Low | Complete | @lukew3 | 9-4= | 5 | | Multiplication | 4 | Low | In Progress | @lukew3 | 4*6= | 24 | | Division | 5 | Low | In Progress | @lukew3 | 4/2= | 2 | - | Factoring | - | Medium | Not Started | - | x^2+x-6 | (x-2)(x+3) | | Power Rule Differentiation | - | Medium | Not Started | - | x^5 | 5x^4 | From 0e08c1e6a9be3611330d59dd50725491e90d80b9 Mon Sep 17 00:00:00 2001 From: lukew3 Date: Mon, 5 Oct 2020 13:41:06 -0400 Subject: [PATCH 03/14] set param defaults on addition and subtraction, readme formatting --- README.md | 16 ++++++++-------- mathGenerator/generator.py | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 65bdf2b..27c7b42 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ To try out generators, go to todarith.ml/generate ## List of Generators -| Skill | Id | Difficulty | Current Status | Contributors | Example problem | Example Solution | -|----------------------------|------|---------------|----------------|--------------|-----------------|-------------------| -| Addition | 2 | Low | Complete | @lukew3 | 1+5= | 6 | -| Subtraction | 3 | Low | Complete | @lukew3 | 9-4= | 5 | -| Multiplication | 4 | Low | In Progress | @lukew3 | 4*6= | 24 | -| Division | 5 | Low | In Progress | @lukew3 | 4/2= | 2 | -| Factoring | - | Medium | Not Started | - | x^2+x-6 | (x-2)(x+3) | -| Power Rule Differentiation | - | Medium | Not Started | - | x^5 | 5x^4 | +| Id | Skill | Ex. problem | Ex. Solution | Usage | Status | +|------|----------------------------|-------------|---------------|----------------------------------|-------------| +| 2 | Addition | 1+5= | 6 | addition(maxSum, maxAddend) | Complete | +| 3 | Subtraction | 9-4= | 5 | subtraction(maxMinuend, maxDiff) | Complete | +| 4 | Multiplication | 4*6= | 24 | | In Progress | +| 5 | Division | 4/2= | 2 | | In Progress | +| - | Factoring | x^2+x-6 | (x-2)(x+3) | | Not Started | +| - | Power Rule Differentiation | x^5 | 5x^4 | | Not Started | diff --git a/mathGenerator/generator.py b/mathGenerator/generator.py index 9613219..c3fcb0b 100644 --- a/mathGenerator/generator.py +++ b/mathGenerator/generator.py @@ -1,6 +1,6 @@ import random -def addition(maxSum, maxAddend): +def addition(maxSum = 99, maxAddend = 50): """ DESCRIPTION: Generates addition problems with positive addends less than maxAddend and sum less than maxSum @@ -18,7 +18,7 @@ def addition(maxSum, maxAddend): solution = str(c) return problem, solution -def subtraction(maxDiff, maxMinuend): +def subtraction(maxMinuend = 99, maxDiff = 99): """ DESCRIPTION: Generates subtraction problems with difference between 0 and maxDiff. Minuend and subtrahend are between 0 and maxMinuend. @@ -35,3 +35,5 @@ def subtraction(maxDiff, maxMinuend): problem = str(a) + "-" + str(b) + "=" solution = str(c) return problem, solution + +print(subtraction()) From 4196e245f33f988c3234f14920767ca6afa00f2d Mon Sep 17 00:00:00 2001 From: lukew3 Date: Mon, 5 Oct 2020 13:44:38 -0400 Subject: [PATCH 04/14] additional readme formatting --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 27c7b42..56dadc0 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ To try out generators, go to todarith.ml/generate ## List of Generators -| Id | Skill | Ex. problem | Ex. Solution | Usage | Status | -|------|----------------------------|-------------|---------------|----------------------------------|-------------| -| 2 | Addition | 1+5= | 6 | addition(maxSum, maxAddend) | Complete | -| 3 | Subtraction | 9-4= | 5 | subtraction(maxMinuend, maxDiff) | Complete | -| 4 | Multiplication | 4*6= | 24 | | In Progress | -| 5 | Division | 4/2= | 2 | | In Progress | -| - | Factoring | x^2+x-6 | (x-2)(x+3) | | Not Started | -| - | Power Rule Differentiation | x^5 | 5x^4 | | Not Started | +| Id | Skill | Example problem | Example Solution | Function Name | Status | +|------|----------------------------|-----------------|-------------------|----------------|-------------| +| 2 | Addition | 1+5= | 6 | addition | Complete | +| 3 | Subtraction | 9-4= | 5 | subtraction | Complete | +| 4 | Multiplication | 4*6= | 24 | | In Progress | +| 5 | Division | 4/2= | 2 | | In Progress | +| - | Factoring | x^2+x-6 | (x-2)(x+3) | | Not Started | +| - | Power Rule Differentiation | x^5 | 5x^4 | | Not Started | From 0effa0c3a7272e301e6d445f477f2307b609d494 Mon Sep 17 00:00:00 2001 From: lukew3 Date: Tue, 13 Oct 2020 12:42:38 -0400 Subject: [PATCH 05/14] Changed to class-based generators --- CONTRIBUTING.md | 13 +++++++++- mathGenerator/generator.py | 51 ++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c81e82..4d9b6ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,17 @@ This project was created with contributions at it's core. We need your help to e ## How You Can Help ### Coding Generators -As of right now, all of our generators are being coded in python. Each generator should be contained in a function. Your function should look something like the following: +As of right now, all of our generators are being coded in python. Your generator will be an object of the Generator class and will have a function created seperately. +Your object instantiation should follow this format: +``` +#g = Generator("", <id>, <generalized problem>, <generalized solution>, <function name>) + +``` +and look something like this: +``` +g2 = Generator("Addition", 2, "a+b=", "c", addition) +``` +Your function should look something like the following: ``` def addition(maxSum, maxAddend): """ @@ -25,6 +35,7 @@ def addition(maxSum, maxAddend): solution = str(c) return problem, solution ``` + Before coding, please check README.md to see if someone has already created the generator you plan to make. Skillid is determined by the next available id as can be determined in the table. diff --git a/mathGenerator/generator.py b/mathGenerator/generator.py index c3fcb0b..2be0ec8 100644 --- a/mathGenerator/generator.py +++ b/mathGenerator/generator.py @@ -1,16 +1,25 @@ import random +# || 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 + + def __str__(self): + return str(self.id) + " " + self.title + " " + self.generalProb + " " + self.generalSol + + def __call__(self): + return self.func() + + +# || Functions + def addition(maxSum = 99, maxAddend = 50): - """ - DESCRIPTION: - Generates addition problems with positive addends less than maxAddend and sum less than maxSum - SKILLID: - 2 - PROBLEM: - "a+b=" - SOLUTION: - "c" - """ a = random.randint(0, maxAddend) b = random.randint(0, min((maxSum-a), maxAddend)) #The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well c = a+b @@ -19,16 +28,6 @@ def addition(maxSum = 99, maxAddend = 50): return problem, solution def subtraction(maxMinuend = 99, maxDiff = 99): - """ - DESCRIPTION: - Generates subtraction problems with difference between 0 and maxDiff. Minuend and subtrahend are between 0 and maxMinuend. - SKILLID: - 3 - PROBLEM: - "a-b=" - SOLUTION: - "c" - """ a = random.randint(0, maxMinuend) b = random.randint(max(0, (a-maxDiff)), a) c = a-b @@ -36,4 +35,14 @@ def subtraction(maxMinuend = 99, maxDiff = 99): solution = str(c) return problem, solution -print(subtraction()) +# || Class Instances + +#Format is: +#g<id> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>) +g2 = Generator("Addition", 2, "a+b=", "c", addition) +g3 = Generator("Subtraction", 3, "a-b=", "c", subtraction) + +# || Testing Zone +print(g2) +print(g2()) +print(g3()) From b29dee7b6416b1627adebc0ff0db099c03a8b1ca Mon Sep 17 00:00:00 2001 From: Luke Weiler <lukew25073@gmail.com> Date: Tue, 13 Oct 2020 12:50:34 -0400 Subject: [PATCH 06/14] Create python-publish.yml --- .github/workflows/python-publish.yml | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..4e1ef42 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From 630ea5ba332eb13711d5fbefd1a385437baf0032 Mon Sep 17 00:00:00 2001 From: lukew3 <lukew25073@gmail.com> Date: Tue, 13 Oct 2020 12:54:10 -0400 Subject: [PATCH 07/14] Test pypi --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 56dadc0..7b87d47 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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. -To try out generators, go to todarith.ml/generate +To try out generators, go to http://todarith.ml/generate ## List of Generators From 82ea6a429a2bad409e76aae16521241cfd843541 Mon Sep 17 00:00:00 2001 From: lukew3 <lukew25073@gmail.com> Date: Tue, 13 Oct 2020 14:06:11 -0400 Subject: [PATCH 08/14] 1.0.1 formatting fixes --- CONTRIBUTING.md | 16 +++------------- README.md | 2 +- {mathGenerator => mathgenerator}/__init__.py | 0 .../generator.py => mathgenerator/mathgen.py | 13 ++++--------- setup.py | 8 ++++---- 5 files changed, 12 insertions(+), 27 deletions(-) rename {mathGenerator => mathgenerator}/__init__.py (100%) rename mathGenerator/generator.py => mathgenerator/mathgen.py (77%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d9b6ee..556fd76 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,26 +8,16 @@ This project was created with contributions at it's core. We need your help to e As of right now, all of our generators are being coded in python. Your generator will be an object of the Generator class and will have a function created seperately. Your object instantiation should follow this format: ``` -#g<id> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>) +#<title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>) ``` and look something like this: ``` -g2 = Generator("Addition", 2, "a+b=", "c", addition) +addition = Generator("Addition", 2, "a+b=", "c", additionFunc) ``` Your function should look something like the following: ``` -def addition(maxSum, maxAddend): - """ - DESCRIPTION: - Generates addition problems with positive addends less than maxAddend and sum less than maxSum - SKILLID: - 2 - PROBLEM: - "a+b=" - SOLUTION: - "c" - """ +def additionFunc(maxSum, maxAddend): a = random.randint(0, maxAddend) b = random.randint(0, min((maxSum-a), maxAddend)) #The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well c = a+b diff --git a/README.md b/README.md index 7b87d47..a413aa2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 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. To try out generators, go to http://todarith.ml/generate diff --git a/mathGenerator/__init__.py b/mathgenerator/__init__.py similarity index 100% rename from mathGenerator/__init__.py rename to mathgenerator/__init__.py diff --git a/mathGenerator/generator.py b/mathgenerator/mathgen.py similarity index 77% rename from mathGenerator/generator.py rename to mathgenerator/mathgen.py index 2be0ec8..0c6d444 100644 --- a/mathGenerator/generator.py +++ b/mathgenerator/mathgen.py @@ -19,7 +19,7 @@ class Generator: # || Functions -def addition(maxSum = 99, maxAddend = 50): +def additionFunc(maxSum = 99, maxAddend = 50): a = random.randint(0, maxAddend) b = random.randint(0, min((maxSum-a), maxAddend)) #The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well c = a+b @@ -38,11 +38,6 @@ def subtraction(maxMinuend = 99, maxDiff = 99): # || Class Instances #Format is: -#g<id> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>) -g2 = Generator("Addition", 2, "a+b=", "c", addition) -g3 = Generator("Subtraction", 3, "a-b=", "c", subtraction) - -# || Testing Zone -print(g2) -print(g2()) -print(g3()) +#<title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>) +addition = Generator("Addition", 2, "a+b=", "c", additionFunc) +subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) diff --git a/setup.py b/setup.py index b1f5269..0c36b2a 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,10 @@ from setuptools import setup, find_packages setup( - name='mathGenerator', - version='1.0.0', + name='mathgenerator', + version='1.0.1', description='An open source solution for generating math problems', - url='https://github.com/todarith/mathGenerator', + url='https://github.com/todarith/mathgenerator', author='Luke Weiler', author_email='lukew25073@gmail.com', license='MIT', @@ -14,7 +14,7 @@ setup( ], entry_points={ 'console_scripts': [ - 'mathGenerator=mathGenerator.mainGen:main' + 'mathgenerator=mathgenerator.generator:main' ], }, ) From 4aa2e021b3b54e2450e187a77e5d8064009951e7 Mon Sep 17 00:00:00 2001 From: lukew3 <lukew25073@gmail.com> Date: Tue, 13 Oct 2020 14:11:28 -0400 Subject: [PATCH 09/14] subtractionFunc naming error --- mathgenerator/mathgen.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0c6d444..0829dc7 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -27,7 +27,7 @@ def additionFunc(maxSum = 99, maxAddend = 50): solution = str(c) return problem, solution -def subtraction(maxMinuend = 99, maxDiff = 99): +def subtractionFunc(maxMinuend = 99, maxDiff = 99): a = random.randint(0, maxMinuend) b = random.randint(max(0, (a-maxDiff)), a) c = a-b diff --git a/setup.py b/setup.py index 0c36b2a..27cc2a5 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='mathgenerator', - version='1.0.1', + version='1.0.2', description='An open source solution for generating math problems', url='https://github.com/todarith/mathgenerator', author='Luke Weiler', From 8dda34f6b6b0ea05d0c74d16f270496f62e0eebc Mon Sep 17 00:00:00 2001 From: lukew3 <lukew25073@gmail.com> Date: Wed, 14 Oct 2020 11:47:50 -0400 Subject: [PATCH 10/14] readme edits --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a413aa2..9c005dd 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,29 @@ # 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. -To try out generators, go to http://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. + +## Usage +The project can be install via pip +``` +pip install mathgenerator +``` +Here is an example of how you would generate an addition problem: +``` +from mathgenerator import mathgen + +#generate an addition problem +problem, solution = mathgen.addition() +``` ## List of Generators | Id | Skill | Example problem | Example Solution | Function Name | Status | |------|----------------------------|-----------------|-------------------|----------------|-------------| | 2 | Addition | 1+5= | 6 | addition | Complete | | 3 | Subtraction | 9-4= | 5 | subtraction | Complete | -| 4 | Multiplication | 4*6= | 24 | | In Progress | -| 5 | Division | 4/2= | 2 | | In Progress | +| 4 | Multiplication | 4*6= | 24 | | Not Started | +| 5 | Division | 4/2= | 2 | | Not Started | | - | Factoring | x^2+x-6 | (x-2)(x+3) | | Not Started | | - | Power Rule Differentiation | x^5 | 5x^4 | | Not Started | From dc3e40bafeab646941c8fc312811cff357573281 Mon Sep 17 00:00:00 2001 From: samuele <samueledoria@gmail.com> Date: Wed, 14 Oct 2020 17:48:31 +0200 Subject: [PATCH 11/14] Added multiplication and division --- mathgenerator/mathgen.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0829dc7..96e9c47 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -35,9 +35,27 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99): solution = str(c) return problem, solution +def multiplicationFunc(maxRes = 99, maxMulti = 99): + a = random.randint(0, maxMulti) + b = random.randint(0, min(maxRes, maxMulti)) + c = a*b + problem = str(a) + "*" + str(b) + "=" + solution = str(c) + return problem, solution + +def divisionFunc(maxRes = 99, maxDivid = 99): + a = random.randint(0, maxDivid) + b = random.randint(0, min(maxRes, maxDivid)) + c = a/b + problem = str(a) + "/" + str(b) + "=" + solution = str(c) + return problem, solution # || Class Instances #Format is: #<title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>) addition = Generator("Addition", 2, "a+b=", "c", additionFunc) subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) +multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) +division = Generator("Division", 5, "a/b=", "c", divisionFunc) + From 91b23a4c666f2442db41aef480a7649c1be13c6e Mon Sep 17 00:00:00 2001 From: akash khamkar <49859828+xatriya@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:13:33 +0530 Subject: [PATCH 12/14] new 1s binary complement generated added . new 1s binary complement problem generator added . --- mathgenerator/mathgen.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 96e9c47..6ffa7ba 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -50,6 +50,19 @@ def divisionFunc(maxRes = 99, maxDivid = 99): problem = str(a) + "/" + str(b) + "=" solution = str(c) return problem, solution + +def binary_1s_Complement(maxDigits = 10): + question = '' + answer = '' + for i in range(random.randint(1,maxDigits)): + temp = str(random.randint(0, 1)) + question += temp + answer += "0" if temp == "1" else "1" + + problem = question + solution = answer + return problem, solution + # || Class Instances #Format is: @@ -58,4 +71,5 @@ addition = Generator("Addition", 2, "a+b=", "c", additionFunc) subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) +binary_complement_1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binary_1s_Complement) From 293fd0b65c412eb6ec323d8c16ec5c612f384ec2 Mon Sep 17 00:00:00 2001 From: akash khamkar <49859828+xatriya@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:20:47 +0530 Subject: [PATCH 13/14] changed names --- mathgenerator/mathgen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 6ffa7ba..b027f41 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -51,7 +51,7 @@ def divisionFunc(maxRes = 99, maxDivid = 99): solution = str(c) return problem, solution -def binary_1s_Complement(maxDigits = 10): +def binaryComplement1sFunc(maxDigits = 10): question = '' answer = '' for i in range(random.randint(1,maxDigits)): @@ -71,5 +71,5 @@ addition = Generator("Addition", 2, "a+b=", "c", additionFunc) subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) -binary_complement_1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binary_1s_Complement) +binaryComplement1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binaryComplement1sFunc) From 7060e19217bcd850368626352e3277e7bb512f07 Mon Sep 17 00:00:00 2001 From: Satyajeet-code <56536469+Satyajeet-code@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:36:43 +0530 Subject: [PATCH 14/14] Update mathgen.py --- mathgenerator/mathgen.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index b027f41..1d80853 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -63,6 +63,14 @@ def binaryComplement1sFunc(maxDigits = 10): solution = answer return problem, solution +def moduloFunc(maxRes = 99, maxModulo= 99): + a = random.randint(0, maxModulo) + b = random.randint(0, min(maxRes, maxModulo)) + c = a%b + problem = str(a) + "%" + str(b) + "=" + solution = str(c) + return problem, solution + # || Class Instances #Format is: @@ -72,4 +80,5 @@ subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) binaryComplement1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binaryComplement1sFunc) +modulo division = Generator("Modulo Division", 6, "a%b=", "c", moduloFunc)