1 Star 0 Fork 0

fanyangchu/PythonCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Type of angles of a triangle.py 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
IndrajaNaik 提交于 2020-10-03 02:27 . Angles of triangle program
#This program will return the type of the triangle.
#User has to enter the angles of the triangle in degrees.
def angle_type():
angles = []
myDict = {"All angles are less than 90°.":"Acute Angle Triangle","Has a right angle (90°)":"Right Angle Triangle",
"Has an angle more than 90°":"Obtuse Angle triangle"}
display = input("**************Enter the angles of your triangle to know it's type*********")
angle1 = int(input("Enter angle1 : "))
if(angle1 < 180 and angle1 > 0):
angles.append(angle1)
else:
print("Please enter a value less than 180°")
angle1 = int(input())
angles.append(angle1)
angle2 = int(input("Enter angle2 : "))
if(angle2 < 180 and angle2 > 0):
angles.append(angle2)
else:
print("Please enter a value less than 180°")
angle2 = int(input())
angles.append(angle2)
angle3 = int(input("Enter angle3 : "))
if(angle3 < 180 and angle3 > 0):
angles.append(angle3)
else:
print("Please enter a value less than 180°")
angle3 = int(input())
angles.append(angle3)
sum_of_angles = angle1 + angle2 +angle3
if(sum_of_angles > 180 or sum_of_angles < 180):
print("It is not a triangle!Please enter valid angles.")
return -1
print("You have entered : " +str(angles))
if(angle1 >= 90 or angle2 >= 90 or angle3 >= 90):
print(myDict.get("Has a right angle (90°)"))
elif(angle1 < 90 and angle2 < 90 and angle3 < 90):
print(myDict.get("All angles are less than 90°."))
elif(angle1 > 90 or angle2 > 90 or angle3 > 90):
print(myDict.get("Has an angle more than 90°"))
angle_type()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fanych/pythoncode.git
git@gitee.com:fanych/pythoncode.git
fanych
pythoncode
PythonCode
master

搜索帮助