求正方形的面积和周长
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())