added area of circle given center and a point

This commit is contained in:
BiscuitCandy
2021-10-08 18:58:10 -07:00
committed by GitHub
parent 576be175a9
commit 820775e87a

View File

@@ -0,0 +1,27 @@
from .__init__ import *
from math import cos, sin, pi
def gen_func(maxCoordinate = 10, maxRadius=10, format='string'):
r = random.randint(0, maxRadius)
center_x = random.randint(-maxCoordinate, maxCoordinate)
center_y = random.randint(-maxCoordinate, maxCoordinate)
angle = random.choice([0, pi//6, pi//2, pi, pi+pi//6, 3*pi//2])
point_x = center_x + round(r*cos(angle), 2)
point_y = center_y + round(r*sin(angle), 2)
area = round(pi * r * r, 2)
if format == 'string':
problem = f"Area of circle with center ({center_x},{center_y}) and passing through ({point_x}, {point_y}) is"
return problem, str(area)
elif format == 'latex':
return "Latex unavailable"
else:
return center_x, center_y, point_x, point_y, area
area_of_circle = Generator("Area of Circle given center and a point on circle", 789, gen_func,
["maxCoordinate = 10", "maxRadius=10"])