mathgenerator

mathgenerator

Fork of https://github.com/lukew3/mathgenerator
Adding more Physics and Computer Science questions

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://mathgenerator-demo.netlify.app

See CONTRIBUTING.md for information about how to contribute.

Table of Contents

Installation

The project can be install via pip

pip install mathgenerator

Usage

Here is an example of how you would generate an addition problem:

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. 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

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

 1"""
 2.. include:: ../README.md
 3"""
 4
 5from .algebra import *
 6from .basic_math import *
 7from .calculus import *
 8from .computer_science import *
 9from .geometry import *
10from .misc import *
11from .physics import *
12from .statistics import *
13
14from ._gen_list import gen_list
15
16
17# [funcname, subjectname]
18def get_gen_list():
19    return gen_list
20
21
22def gen_by_id(id, *args, **kwargs):
23    return globals()[gen_list[id][0]](*args, **kwargs)
24
25
26# Legacy Functions
27def getGenList():
28    return gen_list
29
30
31def genById(id, *args, **kwargs):
32    return globals()[gen_list[id][0]](*args, **kwargs)
def get_gen_list():
19def get_gen_list():
20    return gen_list
def gen_by_id(id, *args, **kwargs):
23def gen_by_id(id, *args, **kwargs):
24    return globals()[gen_list[id][0]](*args, **kwargs)
def getGenList():
28def getGenList():
29    return gen_list
def genById(id, *args, **kwargs):
32def genById(id, *args, **kwargs):
33    return globals()[gen_list[id][0]](*args, **kwargs)