查找圆的顶部x和y坐标

时间:2018-10-18 11:53:45

标签: python

以下代码用于打印出顶点的半径,面积和坐标。

我正在努力解决最后一部分。这是我的代码:

pi = 3.14

class Circle(object):
    def __init__(self, x0, y0, R):
        self.x0, self.y0, self.R = x0, y0, R

    def area(self):
        return pi*self.R**2

    def circumference(self):
        return 2*pi*self.R

c = Circle(2, -1, 5)
print('A circle with radius %g at (%g, %g) has area %g' % (c.R, c.x0, c.y0, c.area()))

这段代码给出了半径和面积,但是我不知道该怎么做才能获得圆的顶点。

1 个答案:

答案 0 :(得分:0)

pi = 3.14

class Circle:
    def __init__(self, x0, y0, R):
        self.x0, self.y0, self.R = x0, y0, R

    def area(self):
        return pi*self.R**2

    def circumference(self):
        return 2*pi*self.R
    def maxPoint(self):
        return (self.x0, self.y0+self.R)

circle = Circle(1,1,1)
print( circle.maxPoint() )