本文整理汇总了Python中circle.Circle.radius方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.radius方法的具体用法?Python Circle.radius怎么用?Python Circle.radius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.radius方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nonsense_radius
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_nonsense_radius():
"""
Make sure we can't create a Circle object with a negative or zero
radius.
"""
with pytest.raises(ValueError):
c = Circle(-1.234)
with pytest.raises(ValueError):
c = Circle(0)
c = Circle(1.234)
with pytest.raises(ValueError):
c.radius = -1.234
with pytest.raises(ValueError):
c.radius = 0
示例2: test_area2
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_area2():
"""
area should change if radius changes
"""
c = Circle(4)
c.radius = 2
assert c.get_area() == math.pi * 4
示例3: test_change_radius
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_change_radius():
c = Circle(3)
c.radius = 4
assert c.radius == 4
示例4: test_set_radius
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_set_radius():
c = Circle(3)
c.radius = 5
assert c.radius == 5
示例5: test_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_diameter():
c = Circle(3)
c.radius=2
assert c.diamter==4
示例6: test_radius_chage
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_radius_chage():
c = Circle(3)
c.radius = 4
assert c.diameter == 8
示例7: test_change_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_change_diameter():
c = Circle(3)
c.radius = 4
assert c.diameter == 8
示例8: test_no_radius
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_no_radius():
with pytest.raises(TypeError):
c = Circle()
c.radius = 4
示例9: test_init
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_init():
c = Circle(3)
c.radius = 4
示例10: test_diameter2
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_diameter2():
c = Circle(5)
c.radius = 4
assert c.diameter == 8
示例11: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
"""
from circle import Circle
print "creating a Circle with radius 4"
c = Circle(4)
print "the radius:", c.radius
print "the diameter:", c.diameter
print "the area:", c.area
print "the repr():", repr(c)
print "the str():", str(c)
print
print "setting the radius to 2:"
c.radius = 2
print "the radius:", c.radius
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
示例12: test_diameter2
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_diameter2():
c = Circle(4)
c.radius = 2
assert c.diameter == 4
示例13: test_radius_change
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_radius_change(): #does diameter change when radius changes?
c = Circle(3)
c.radius = 4
assert c.diameter == 8