我试图为一个三角形分类程序创建一个决策表,代码如下所示。更新
def tritype(a, b, c):
if ((a ^ 2 + b ^ 2) == c^2):
return "Right Triangle"
if ((a + b) == c):
return "Isosceles Triangle"
if (a + b > c):
return "Scalene Triangle"
if ((a == b) and (b == c) and (a == c)):
return "Equilateral Triangle"
if ((a < 1) or (b < 1) or (c < 1)):
return "Negative Lenght Error"
else:
return "Invalid Triangle Error"
这是我到目前为止的情况
第1步:列出所有条件和效果:
^{pr2}$我不确定如何将上述信息放入表中。在
要生成与上面显示的表类似的表,只需使用
\t
作为间距和一些简单的打印命令。在要在决策表数组中搜索条目,只需迭代所有元素。在
^{pr2}$这是一个相当简单的解决办法,但我认为就你的目的而言,这是完全足够的。在
相关问题 更多 >
编程相关推荐