本文整理汇总了Python中square.Square.area方法的典型用法代码示例。如果您正苦于以下问题:Python Square.area方法的具体用法?Python Square.area怎么用?Python Square.area使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类square.Square
的用法示例。
在下文中一共展示了Square.area方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from square import Square [as 别名]
# 或者: from square.Square import area [as 别名]
def main():
sh = Shape()
print sh
t = Triangle(5, 10)
print t.area()
print "%s Static Method" % t.static_area(10, 20)
s = Square(20)
print s.area()
print s.perimeter()
示例2: SquareTest
# 需要导入模块: from square import Square [as 别名]
# 或者: from square.Square import area [as 别名]
class SquareTest(unittest.TestCase):
def setUp(self):
self.square = Square(side=3)
def test_it_has_a_side(self):
self.square.side |should| equal_to(3)
def test_it_changes_its_side(self):
self.square.side = 5
self.square.side |should| equal_to(5)
def test_it_calculates_its_area(self):
self.square.area() |should| equal_to(9)
示例3: TestSquare
# 需要导入模块: from square import Square [as 别名]
# 或者: from square.Square import area [as 别名]
class TestSquare(unittest.TestCase):
def setUp(self):
self.square = Square(5)
def test_perimeter(self):
self.assertEqual(self.square.perimeter(), 20)
def test_area(self):
self.assertEqual(self.square.area(), 25)
示例4: Square
# 需要导入模块: from square import Square [as 别名]
# 或者: from square.Square import area [as 别名]
from square import Square
s = Square(7)
s.set_center([0, 0])
s.set_color("Yellow")
s.name = "Hally"
print "Area of %s is %d" % (s.name, s.area())
s.print_s()