From 15ce6be9ac7d2210dafb1f0d55cbad59de3e5aac Mon Sep 17 00:00:00 2001 From: Nuclear03020704 Date: Mon, 20 Dec 2021 22:12:38 +0700 Subject: [PATCH] Add new generator: volume of pyramid --- .../funcs/geometry/volume_pyramid.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 mathgenerator/funcs/geometry/volume_pyramid.py diff --git a/mathgenerator/funcs/geometry/volume_pyramid.py b/mathgenerator/funcs/geometry/volume_pyramid.py new file mode 100644 index 0000000..69a378b --- /dev/null +++ b/mathgenerator/funcs/geometry/volume_pyramid.py @@ -0,0 +1,22 @@ +from .__init__ import * + + +def gen_func(maxLength=20, maxWidth=20, maxHeight=50, unit='m', format='string'): + l = random.randint(1, maxLength) + w = random.randint(1, maxWidth) + h = random.randint(1, maxHeight) + + ans = (l*w*h)/3 + + if format == 'string': + problem = f"Volume of cone with base length = {l} {unit}, base width = {w} {unit} and height = {h} {unit} is" + solution = f"{ans} {unit}^3" + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return l, w, h, ans, unit + + +volume_pyramid = Generator("Volume of pyramid", 112, gen_func, + ["maxLength=20", "maxWidth=20", "maxHeight=50", "unit='m'"]) \ No newline at end of file