||
import math
a,b,c = input("Input the length of sides separated by comma:")
if a + b > c and a + c > b and b + c > a:
p = (a + b + c)/2.0
temp = p * (p - a) * (p - b) * (p - c)
area = math.sqrt(temp)
if a == b or b == a or c == a:
if a == b == c:
res = "equilateral triangle"
elif math.fabs(a**2 + b**2 - c**2) < 1e-6 or math.fabs(b**2 + c**2 - a**2) < 1e-6 or math.fabs(c**2 + a**2 - b**2) < 1e-6:
res = "isosceles triangle"
elif math.fabs(a**2 + b **2 - c**2) < 1e-6 or (b**2 + c **2 - a**2) < 1e-6 or (c**2 + a **2 - b**2) < 1e-6:
res = "rightangled triangle"
else:
res = "Common triangle"
else:
res = "Not triangle"
if res != "Not triangle":
print("Area for this triangle is", area)
print("It is a", res)
else:
print("Not a triangle")
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 03:08
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社