程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python] judge triangle type

編輯:Python
 I didn't want to upload this , In order to maintain CSDN medal , I hope to understand .
There is no technical content , Is to test some logic , No joy, no spray. .
Enter three numbers ( Floating point data support ), Determine whether it is a triangle and its type , Side length range [1-200].
The notes are perfect , Self understanding .

 execution environment Ubuntu18.04 Pycharm

Code:

def funtest():
edge_list = [0, 0, 0]
edge_list[0] = float(input("Edge1:"))
edge_list[1] = float(input("Edge2:"))
edge_list[2] = float(input("Edge3:"))
edge_list.sort()
temp1 = edge_list[0] ** 2
temp2 = edge_list[1] ** 2
temp3 = edge_list[2] ** 2
if (edge_list[0] < 1 or edge_list[1] > 200) and (edge_list[1] < 1 or edge_list[1] > 200) and (
edge_list[2] < 1 or edge_list[2] > 200):
print("Edge Error")
return
temp = temp1 + temp2
if edge_list[0] + edge_list[1] > edge_list[2]:
if edge_list[0] == edge_list[1] or edge_list[1] == edge_list[2] or edge_list[2] == edge_list[0]:
if temp == temp3:
print(" Right angle isosceles ")
elif edge_list[0] == edge_list[1] and edge_list[1] == edge_list[2]:
print(" Equilateral ")
else:
print(" Isosceles ")
elif temp == temp3:
print(" Right angle ")
else:
print(" commonly ")
else:
print(" Non triangle ")
funtest()

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved