本文整理汇总了Python中circle.Circle.area方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.area方法的具体用法?Python Circle.area怎么用?Python Circle.area使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.area方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_area
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
def test_set_area():
c = Circle(4)
try:
c.area = 10
except AttributeError as error:
assert error.message == "can't set attribute"
else:
assert False
示例2: test_set_area
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
def test_set_area():
c = Circle(4)
with pytest.raises(AttributeError):
c.area = 44
示例3: test_no_set_area
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
def test_no_set_area():
c = Circle(4.52)
with pytest.raises(AttributeError):
c.area = 5.67
示例4: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
from circle import Circle
bbd = 25.1
# NameError: name 'bbd_to_radius' is not defined
c = Circle(bbd_to_radius(bbd))
print 'A circle with a bbd of 25.1'
print 'has a radius of',c.radius
print 'and an area of',c.area()
print
示例5: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
from circle import Circle
c = Circle(4)
c.set_center([0, 0])
c.set_color("Yellow")
c.name = "Sun"
print "Area of %s is %f" % (c.name, c.area())
示例6: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
# Tutorial
from circle import Circle
print "Citrus version", Circle.version
c = Circle(10)
print "A circle of radius", c.radius
print "has an area of", c.area()
print
示例7: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
print "the diameter:", c.diameter
print "the area:", c.area
print
print "setting the diameter to 6:"
c.diameter = 6
print "the radius:", c.radius
print "the diameter:", c.diameter
print "the area:", c.area
print
print "trying to delete the diameter"
try:
del c.diameter
except Exception as err:
print "Whoops:", err
print
print "trying to set the area"
try:
c.area = 40.0
except Exception as err:
print "Whoops:", err
c1 = Circle(2)
c2 = Circle(4)
print
print "adding two circles together"
print c1 + c2
示例8: test_areaset
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
def test_areaset():
c = Circle(2)
with pytest.raises(AttributeError):
c.area = 4*pi
示例9: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import area [as 别名]
from circle import Circle
c = Circle(4)
c.set_center([0, 0])
c.set_color("Yellow")
print "Area of %s %sis %f" % (c.get_color(), c.name, c.area())