Files
mathgenerator/README.md
2022-12-27 14:32:23 -05:00

68 lines
2.6 KiB
Markdown

# mathgenerator
A math problem generator, created for the purpose of giving teachers and students the means to easily get access to random math exercises to suit their needs.
To try out generators, go to <https://lukew3.github.io/mathgenerator>
See [CONTRIBUTING.md](https://github.com/lukew3/mathgenerator/blob/main/CONTRIBUTING.md) for information about how to contribute.
## Table of Contents
* [Installation](#installation)
* [Usage](#usage)
* [Documentation](#documentation)
## Installation
The project can be install via pip
```bash
pip install mathgenerator
```
## Usage
Here is an example of how you would generate an addition problem:
```python
import mathgenerator
#generate an addition problem
problem, solution = mathgenerator.addition()
#another way to generate an addition problem using genById()
problem, solution = mathgenerator.genById(0)
```
You may prefer to use `import mathgenerator as mg` and run functions like `mg.addition()` so that you don't have to type as much.
<!--
### Creating a worksheet
If you wish to create a worksheet, you can use the [worksheetgen](https://github.com/lukew3/worksheetgen) package. Install this with `pip install worksheetgen`. Here is an example of how a worksheet would be generated.
```
from mathgenerator import mathgen
from worksheetgen.wg import Worksheet
ws = Worksheet("Worksheet title")
with ws.section('Section 1', description='These are instructions')
# Writes 10 problems generated with id 1, [0] at the end specifies to take problem, and not solution.
for _ in range(10):
ws.add_problem(mathgen.genById(1)[0])
ws.write_pdf()
```
This creates the pdf `ws.pdf` in your current directory
-->
Problem/solution pairs are generated with either:
* `mathgenerator.<generator_name>()` - generates a problem, solution set from the given generator name.
* `mathgenerator.genById(id)` - generates a problem, solution set with generator id provided by the `id` parameter
<!--
#### `format` kwarg
* Pass `format=latex` to return problem and solution set as latex. If latex is not available for that generator, the problem will return the string "Latex unavailable"
* Pass `format=raw` to return just the raw data for each generator. An array of each variable necessary to the generator is returned.
* If you don't pass a value to the format kwarg, the generator will return a problem and answer in asciimath format.
-->
You can also use `getGenList()` to return a list of all generators included in the library in the format:
```
[funcname, subjectname]
```
## Documentation
Documentation can be found at https://lukew3.github.io/mathgenerator