当前位置: 首页>>代码示例>>Python>>正文


Python Circle.area方法代码示例

本文整理汇总了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
开发者ID:Anastomose,项目名称:IntroToPython,代码行数:10,代码来源:circle_test.py

示例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
开发者ID:DZwell,项目名称:sea-c34-python,代码行数:7,代码来源:test_circle2.py

示例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
开发者ID:Anastomose,项目名称:IntroToPython,代码行数:6,代码来源:test_circle.py

示例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
开发者ID:doubledword,项目名称:jkt-thu-2,代码行数:12,代码来源:stage-5.py

示例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())
开发者ID:IanWagener,项目名称:holbertonschool-higher_level_programming,代码行数:9,代码来源:3-main.py

示例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
开发者ID:doubledword,项目名称:jkt-thu-2,代码行数:11,代码来源:stage-1.py

示例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
开发者ID:PythonCHB,项目名称:PythonIntroClass,代码行数:32,代码来源:test_circle.py

示例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 
开发者ID:dcohashi,项目名称:IntroPython2015,代码行数:6,代码来源:test_circle.py

示例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())
开发者ID:bennettbuchanan,项目名称:holbertonschool-higher_level_programming,代码行数:9,代码来源:3-main.py


注:本文中的circle.Circle.area方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。