From c2561e4d0febdda611b2e04ca41f6805c54923ee Mon Sep 17 00:00:00 2001 From: abhijeetgupto <> Date: Thu, 7 Oct 2021 18:32:33 +0000 Subject: [PATCH] added volume of frustum --- .../funcs/geometry/volume_frustum.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 mathgenerator/funcs/geometry/volume_frustum.py diff --git a/mathgenerator/funcs/geometry/volume_frustum.py b/mathgenerator/funcs/geometry/volume_frustum.py new file mode 100644 index 0000000..46fd378 --- /dev/null +++ b/mathgenerator/funcs/geometry/volume_frustum.py @@ -0,0 +1,21 @@ +from .__init__ import * + + +def gen_func(maxR1=20, maxR2 = 20, maxHeight=50, unit='m', format='string'): + h = random.randint(1, maxHeight) + r1 = random.randint(1, maxR1) + r2 = random.randint(1, maxR2) + ans = ((math.pi*h)*(r1**2 + r2**2 + r1*r2))//3 + + if format == 'string': + problem = f"Volume of frustum with height = {h}{unit} and r1 = {r1}{unit} is and r2 = {r1}{unit} is " + solution = f"{ans} {unit}^3" + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return r1, r2, h, ans, unit + + +volume_frustum = Generator("Volume of frustum", 62, gen_func, + ["maxR1=20","maxR2=20", "maxHeight=50", "unit='m'"]) \ No newline at end of file