mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* removed asterisk imports from subject inits * import Generator from the right init level
23 lines
666 B
Python
23 lines
666 B
Python
from ...__init__ import Generator
|
|
import random
|
|
import math
|
|
|
|
|
|
def gen_func(maxRadius=20, maxHeight=50, unit='m', format='string'):
|
|
a = random.randint(1, maxHeight)
|
|
b = random.randint(1, maxRadius)
|
|
ans = int(math.pi * b * b * a * (1 / 3))
|
|
|
|
if format == 'string':
|
|
problem = f"Volume of cone with height = {a}{unit} and radius = {b}{unit} is"
|
|
solution = f"{ans} {unit}^3"
|
|
return problem, solution
|
|
elif format == 'latex':
|
|
return "Latex unavailable"
|
|
else:
|
|
return a, b, ans, unit
|
|
|
|
|
|
volume_cone = Generator("Volume of cone", 39, gen_func,
|
|
["maxRadius=20", "maxHeight=50", "unit='m'"])
|