mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Add new generator: volume of pyramid
This commit is contained in:
22
mathgenerator/funcs/geometry/volume_pyramid.py
Normal file
22
mathgenerator/funcs/geometry/volume_pyramid.py
Normal file
@@ -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'"])
|
||||||
Reference in New Issue
Block a user