import math
class Circle:
def __init__(self,place,r,color):
self.plsce = place
self.r = r
self.color = color
def C(self):
return '周长:{}'.format(math.pi*2*self.r)
def S(self):
return '面积:{}'.format(math.pi*math.pow(self.r,2))
a = Circle((1,0),1,'red')
print(a.C())
print(a.S())
设计一个Circle类,包括圆心位置、半径、颜色等属性。编写构造方法和其他方法,计算周长和面积。请编写程序验证类的功能。
最新推荐文章于 2025-06-01 19:34:47 发布