三角形
def is_primitive(data):
return isinstance(data,(int,float))
def sanjia(a,b,c):
try:
if is_primitive(a) and is_primitive(b) and is_primitive(c) and a>0 and b>0 and c>0:
if a +b > c and a+c>b and b+c>a:
if a == b == c:
print("{} {} {} 这是等边三角形".format(a,b,c))
elif a ==b and b != c:
print("{} {} {} 这是等腰三角形".format(a,b,c))
elif a ==c and b != c:
print("{} {} {} 这是等腰三角形".format(a,b,c))
elif b ==c and a != c:
print("{} {} {} 这是等腰三角形".format(a, b, c))
else:
print("{} {} {}这格三角形的三条变不等".format(a,b,c))
else:
print("{}{}{}这三个数字不能组成三角形".format(a,b,c))
else:
print("输入有误")
except TypeError:
print("输入的数据错误")
if __name__ == "__main__":
den = sanjia(1, 3, 3)
posted on 2025-02-26 18:08 Darren-Frank 阅读(10) 评论(0) 收藏 举报
浙公网安备 33010602011771号