我的账户
码尚云教育

云计算企业项目实战营

亲爱的游客,欢迎!

已有账号,请

如尚未注册?

使用Python写出判断三角形的程序

[复制链接]
云鼎 发表于 2022-9-19 14:24:42 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
某程序规定:"输入三个正数 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]复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注我们
码尚云云计算培训

客服电话:18710061913

周一至周日: 7:00-24:00

码尚云教育( 陕ICP备2023009934号-2 )

Powered by Discuz! X3.4© 2016-2023 Comsenz Inc.