Files
mathgenerator/mathgenerator/funcs/geometry/surface_area_cone.py
Luke Weiler f2efb3751d import with name not asterisk
* import with name not *, remove top level imports

* Fix linter, remove numpy

* Lint fixes

* Comment worksheet generator temporarily
2022-12-19 01:31:08 -05:00

25 lines
749 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)
slopingHeight = math.sqrt(a**2 + b**2)
ans = int(math.pi * b * slopingHeight + math.pi * b * b)
if format == 'string':
problem = f"Surface area of cone with height = {a}{unit} and radius = {b}{unit} is"
solution = f"{ans} {unit}^2"
return problem, solution
elif format == 'latex':
return "Latex unavailable"
else:
return a, b, ans, unit
surface_area_cone = Generator("Surface Area of cone", 38, gen_func,
["maxRadius=20", "maxHeight=50", "unit='m'"])