python - 如何编写 Python if 语句函数来识别 3 个维度是否构成三角形?
问题描述
我需要用 if 语句编写一个函数来查找具有 3 个给定边的三角形是否为三角形。
def makes_triangle(a, b, c):
解决方案
您需要使用三角不等式定理:
def makes_triangle(a, b, c):
return (a+b>c) and (a+c>b) and (b+c>a)
推荐阅读
- reactjs - React Router 5.重定向后未呈现组件
- scala - Scala中的时间序列插值
- javascript - 为什么在 javascript 中没有`import module-name.export1`?
- python-3.x - 有什么方法可以处理错误是目录吗?
- postgresql - PostgreSQL 连接到 localhost,尽管在 application.yaml 中设置了其他地址
- python - cx_freeze 和 pythonnet clr 的问题
- regex - 在 VBA 中使用正则表达式是在使用 accdb 文件的每个应用程序中启用 MS VBScript 正则表达式 5.5 所必需的
- database - ORA-01841 在表之间传递数据而不转换日期。甲骨文 SQL
- flutter - 我正在开发一个博客应用程序,如何在 Flutter 的 TextFormField 中插入图像、音频、视频等媒体文件?
- c# - 使用 Ghostscript 将 PDF 转换为图像