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


Python Circle.radius方法代码示例

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

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

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

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

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

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

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

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

示例9: test_init

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import radius [as 别名]
def test_init():
    c = Circle(3)
    c.radius = 4
开发者ID:Anastomose,项目名称:IntroToPython,代码行数:5,代码来源:test_Circle.py

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

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

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

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


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