python问题求解

编程序,提示用户输入三角形的三个顶点(x1,y1)、(x2,y2)、(x3,y3),然后计算三角形面积,假定输入的三个点能构成三角形。将面积输出到屏幕,输出占7列,保留2位小数,左对齐。


import math
(x1,y1,x2,y2,x3,y3)= eval(input("Please input three point for a triangle:"))
side1 = math.sqrt((x1-x2)**2+(y1-y2)**2)
side2 = math.sqrt((x1-x3)**2+(y1-y3)**2)
side3 = math.sqrt((x2-x3)**2+(y2-y3)**2)
s = (side1+side2+side3)/2
area = math.sqrt(s(s - side1)(s - side2)(s - side3))
print("The area of the triangle is %7.2f"%area)
(x1,y1,x2,y2,x3,y3)= eval(input("请分别输入三角形三个定点坐标:"))
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
b = math.sqrt((x1-x3)**2+(y1-y3)**2)
c = math.sqrt((x2-x3)**2+(y2-y3)**2)
s = (a+b+c)/2.0
area = math.sqrt(s*(s - a)*(s - b)*(s - c))
print("三角形面积为: %-04.2f" %area)