码尚云_西安云计算培训_云计算运维培训机构
标题:
使用Python写出判断三角形的程序
[打印本页]
作者:
云鼎
时间:
2022-9-19 14:24
标题:
使用Python写出判断三角形的程序
某程序规定:"输入三个正数 a 、 b 、 c 分别作为三边的边长构成三角形。通过程序判定所构成的三角形的类型,当此三角形为一般三角形、等腰三角形及等边三角形时,分别作计算 … "。
def isTriabgle():
try:
a= int(input("请输入第一边边长:"))
b = int(input("请输入第一边边长:"))
c = int(input("请输入第一边边长:"))
if(a>0 and b>0 and c>0):
if(a==b==c):
print("等边三角形")
elif((a+b>c and abs(a-b)<c) or (a+c>b and abs(a-c)<b) or (b+c>a and abs(b-c)<a)):
if(a==b or a==c or b==c):
print("等腰三角形")
else:
print("一般三角形")
else:
print("不是三角形0")
except:
print("输入有误")
if __name__=='__main__':
isTriabgle()
[color=rgb(15, 199, 122) !important]
复制代码
欢迎光临 码尚云_西安云计算培训_云计算运维培训机构 (http://www.mashangcloud.com/)
Powered by Discuz! X3.4