本文整理汇总了Python中circle.Circle.diameter方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.diameter方法的具体用法?Python Circle.diameter怎么用?Python Circle.diameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.diameter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_change_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
def test_change_diameter():
c = Circle(2)
assert c.radius == 2
assert c.diameter == 4
c.diameter = 6
assert c.radius == 3
assert c.diameter == 6
示例2: test_change_diameter_float
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
def test_change_diameter_float():
c = Circle(4)
c.diameter = 11
assert c.diameter == 11
assert c.radius == 5.5
示例3: test_set_diamter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
def test_set_diamter():
c = Circle(4)
c.diameter = 11
assert c.radius == 5.5
assert c.diameter == 11
示例4: test_set_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
def test_set_diameter():
c = Circle(4)
c.diameter = 2
assert c.diameter == 2
assert c.radius == 1
示例5: test_set_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
def test_set_diameter():
c = Circle(4.3)
c.diameter = 3.0
assert c.radius == 1.5
assert c.diameter == 3.0
示例6: repr
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
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
except Exception as err:
print "Whoops:", err
print
print "trying to set the area"
try:
c.area = 40.0
示例7: test_set_diameter
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
def test_set_diameter():
c = Circle(4)
c.diameter = 10
assert c.diameter == c.radius * 2
assert c.diameter == 10
示例8: test_diameter_set
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import diameter [as 别名]
def test_diameter_set():
c = Circle(2)
c.diameter = 6
assert (6 == c.diameter)
assert (3 == c.radius)