【Python】编写一个类,求圆的周长和面积

2021-11-01 11:47:59 浏览数 (1)

class Cirle:

def __init__(self, r): # 初始化

self.r =

def c(self): # 计算圆的周长

PI = 3.1415

return 2 * PI * self.

def s(self): # 计算圆的面积

PI = 3.1415

return PI * self.r * self.

if __name__ == "__main__":

c1 = Cirle(4)

c = c1.c()

s = c1.s()

print("圆的周长为 ", c, "面积为 ", s)

0 人点赞