[英]Find the top x and y co-ordinates of a circle
下面的代碼用於打印出頂點的半徑、面積和坐標。
我正在努力解決最后一部分。 這是我的代碼:
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()))
這段代碼給出了半徑和面積,但我不知道該怎么做才能得到圓的頂點。
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() )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.