當前位置: 首頁>>代碼示例>>Python>>正文


Python Rectangle.find_center方法代碼示例

本文整理匯總了Python中rectangle.Rectangle.find_center方法的典型用法代碼示例。如果您正苦於以下問題:Python Rectangle.find_center方法的具體用法?Python Rectangle.find_center怎麽用?Python Rectangle.find_center使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rectangle.Rectangle的用法示例。


在下文中一共展示了Rectangle.find_center方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from rectangle import Rectangle [as 別名]
# 或者: from rectangle.Rectangle import find_center [as 別名]
def main():
    house = Point(10, 9)
    print('House is at X:', house.x)
    print('House is at Y:', house.y)
    work = Point(5, 2)
    print('House to work distance:', house.distance_to(work))

    city = Rectangle(Point(5, 5), 10, 10)
    print('City corner is:', city.bottom_left_corner)
    print('City width:', city.w)
    print('City height:', city.h)
    print('House in city:', city.contains(house))
    print('Work in city:', city.contains(work))

    city_center = city.find_center()
    print('City center:', city_center)

    cats_house = Point(10, 9)
    identical_city = Rectangle(Point(5, 5), 10, 10)
    different_city = Rectangle(Point(13, 13), 10, 10)
    print("My cat's house and mine are equal:", house == cats_house)
    print('Two identical cities are equal:', city == identical_city)
    print('Two different cities are equal:', city == different_city)

    house.move_by(1, -1)
    print('After moving my house:', house)
開發者ID:PdxCodeGuild,項目名稱:Full-Stack-Day-Class,代碼行數:28,代碼來源:main.py


注:本文中的rectangle.Rectangle.find_center方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。