diff --git a/README.md b/README.md index 0e3812e..815a41c 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,8 @@ This creates the pdf `ws.pdf` in your current directory | 112 | [Area of Circle](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_circle.py) | Area of circle with radius 3 | 28.285714285714285 | area_of_circle | `maxRadius=100` | | 113 | [Volume of frustum](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_frustum.py) | Volume of frustum with height = 23m and r1 = 19m is and r2 = 19m is | 15679.0 m^3 | volume_frustum | `maxR1=20` `maxR2=20` `maxHeight=50` `unit='m'` | | 114 | [Equation of line from two points](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/equation_of_line_from_two_points.py) | What is the equation of the line between points (-19,-11) and (-4,20) in slope-intercept form? | 15y = 31x + 424 | equation_of_line_from_two_points | `maxCoordinate=20` `minCoordinate=-20` | +| 115 | [Area of circle given center and a point on it](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py) | Area of circle with center (2,9) and passing through (12.0, 9.0) is? | 314.16 | area_of_circle_given_center_and_point | `maxCoordinate=10` `maxRadius=10` | +| 117 | [Volume of Hemisphere](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/geometry/volume_hemisphere.py) | Volume of hemisphere with radius 6 m = | 452.389 m^3 | volume_hemisphere | `maxRadius=100` | ## misc | Id | Skill | Example problem | Example Solution | Function Name | Kwargs | |------|-------|-----------------|------------------|---------------|--------| @@ -191,6 +193,7 @@ This creates the pdf `ws.pdf` in your current directory | 102 | [Minute to Hour conversion](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/minutes_to_hours.py) | Convert 525 minutes to Hours & Minutes | 8 hours and 45 minutes | minutes_to_hours | `maxMinutes=999` | | 106 | [signum function](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/signum_function.py) | signum of 17 is = | 1 | signum_function | `min=-999` `max=999` | | 109 | [Binomial distribution](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/binomial_distribution.py) | A manufacturer of metal pistons finds that, on average, 32.13% of the pistons they manufacture are rejected because they are incorrectly sized. What is the probability that a batch of 14 pistons will contain no more than 1 rejected pistons? | 3.36 | binomial_distribution | `` | +| 116 | [Factors](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/Factors.py) | Factors of 820 = | [1, 2, 4, 5, 10, 20, 41, 82, 164, 205, 410, 820] | Factors | `maxVal=1000` | ## statistics | Id | Skill | Example problem | Example Solution | Function Name | Kwargs | |------|-------|-----------------|------------------|---------------|--------| diff --git a/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py b/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py new file mode 100644 index 0000000..eb4a555 --- /dev/null +++ b/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py @@ -0,0 +1,27 @@ +from .__init__ import * +from math import cos, sin, pi + + +def gen_func(maxCoordinate = 10, maxRadius=10, format='string'): + r = random.randint(0, maxRadius) + center_x = random.randint(-maxCoordinate, maxCoordinate) + center_y = random.randint(-maxCoordinate, maxCoordinate) + + angle = random.choice([0, pi//6, pi//2, pi, pi+pi//6, 3*pi//2]) + + point_x = center_x + round(r*cos(angle), 2) + point_y = center_y + round(r*sin(angle), 2) + + area = round(pi * r * r, 2) + + if format == 'string': + problem = f"Area of circle with center ({center_x},{center_y}) and passing through ({point_x}, {point_y}) is" + return problem, str(area) + elif format == 'latex': + return "Latex unavailable" + else: + return center_x, center_y, point_x, point_y, area + + +area_of_circle = Generator("Area of Circle given center and a point on circle", 115, gen_func, + ["maxCoordinate = 10", "maxRadius=10"]) diff --git a/mathgenerator/funcs/geometry/volume_hemisphere.py b/mathgenerator/funcs/geometry/volume_hemisphere.py new file mode 100644 index 0000000..4b4bb2d --- /dev/null +++ b/mathgenerator/funcs/geometry/volume_hemisphere.py @@ -0,0 +1,19 @@ +from .__init__ import * + + +def gen_func(maxRadius=100, format='string'): + r = random.randint(1, maxRadius) + ans = round((2 * math.pi / 3) * r**3, 3) + + if format == 'string': + problem = f"Volume of hemisphere with radius {r} m = " + solution = f"{ans} m^3" + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return r, ans + + +volume_sphere = Generator("Volume of Hemisphere", 117, gen_func, + ["maxRadius=100"]) diff --git a/mathgenerator/funcs/misc/Factors.py b/mathgenerator/funcs/misc/Factors.py new file mode 100644 index 0000000..8781bc9 --- /dev/null +++ b/mathgenerator/funcs/misc/Factors.py @@ -0,0 +1,31 @@ +from .__init__ import * + + +def gen_func(maxVal=1000, format='string'): + n = x = random.randint(1, maxVal) + + factors = [] + + for i in range(1, int(n**0.5) + 1) : + if i**2 == n : + factors.append(i) + elif n%i ==0 : + factors.append(i) + factors.append(n//i) + else : + pass + + factors.sort() + + if format == 'string': + problem = f"Factors of {n} = " + solution = factors + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return n, factors + + +common_factors = Generator("Factors", 116, gen_func, + ["maxVal=1000"]) \ No newline at end of file