本文整理汇总了Python中rectangle.Rectangle.perimeter方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.perimeter方法的具体用法?Python Rectangle.perimeter怎么用?Python Rectangle.perimeter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rectangle.Rectangle
的用法示例。
在下文中一共展示了Rectangle.perimeter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RectangleTest
# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import perimeter [as 别名]
class RectangleTest(unittest.TestCase):
def setUp(self):
self.rectangle = Rectangle(width=3, height=2)
def test_it_has_width_and_height(self):
self.rectangle.width |should| equal_to(3)
self.rectangle.height |should| equal_to(2)
def test_it_changes_its_width(self):
self.rectangle.width = 5
self.rectangle.width |should| equal_to(5)
def test_it_changes_its_height(self):
self.rectangle.height = 5
self.rectangle.height |should| equal_to(5)
def test_it_calculates_its_area(self):
self.rectangle.area() |should| equal_to(6)
def test_it_calculates_its_perimeter(self):
self.rectangle.perimeter() |should| equal_to(10)
示例2: printvalue
# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import perimeter [as 别名]
from rectangle import Rectangle
def printvalue(values):
values.perimeter()
print
values.area()
print
firstrec = Rectangle()
secondrec = Rectangle(8.5,12.2)
thirdrec = Rectangle(10.6,10.1)
secondrec.display()
print "for first rectangle, values are perimeter and area respectively",
firstrec.perimeter()
print "for second rectangle, values are perimeter and area respectively",
printvalue(secondrec)
print "for third rectangle, values are perimeter and area respectively",
printvalue(thirdrec)