利用类来计算点是不是在园内《python语言程序设计》2018版--第8章18题第3部分

python 复制代码
  def contains_point(self,other_x,other_y):
        x1 = self.__x
        y1 = self.__y
        x2 = other_x
        y2 = other_y
        countDis = int((pow((x2-x1),2) + pow((y2-y1),2)) ** 0.5)
        if countDis < self.__radius:
            print(f"坐标x:{other_x},y:{other_y},点2在园1内")
            return True
        else:
            print(f"坐标x:{other_x},y:{other_y},点2不在园1内")
            return False


相关推荐
hboot11 小时前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
ZhengEnCi1 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi1 天前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽1 天前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户8358086187911 天前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L2 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅2 天前
海天线算法的前世今生
python·计算机视觉
韩师傅2 天前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L2 天前
LangGraph的MessageState and HumanMessage
python
韩师傅2 天前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉