求正方形的面积和周长

复制代码
 1 class Square:
 2     def __init__(self,length):
 3         self.length = length
 4 
 5     def perimeter(self):
 6         return 4*self.length
 7 
 8     def area(self):
 9         return self.length*self.length
10 
11 square = Square(3)
12 print(square.perimeter())
13 print(square.area())
复制代码

 

posted @   wangmo  阅读(806)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示