首页 > 解决方案 > 如何编写 Python if 语句函数来识别 3 个维度是否构成三角形?

问题描述

我需要用 if 语句编写一个函数来查找具有 3 个给定边的三角形是否为三角形。

 def makes_triangle(a, b, c):

标签: python

解决方案


您需要使用三角不等式定理

def makes_triangle(a, b, c):
    return (a+b>c) and (a+c>b) and (b+c>a)

推荐阅读