码迷,mamicode.com
首页 > 其他好文 > 详细

求正方形的面积和周长

时间:2017-10-29 21:54:51      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:logs   length   style   blog   sel   self   col   bsp   int   

 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())

 

求正方形的面积和周长

标签:logs   length   style   blog   sel   self   col   bsp   int   

原文地址:http://www.cnblogs.com/wangmo/p/7751338.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!