程序被设置为计算三角形的面积。三角形边(a、b、c)是一个输入。该代码只适用于certian数字,而不适用于其他数字。E、 g
当a、b和c分别为: 2,3,4代码正常。 2,3,5 0.00中的输出是错误的。 2,3,6程序打印一个数学域错误
def main():
print "Program calculates the area of a triangle."
print
a, b, c = input("Enter triangle's sides length: ")
s = (a+b+c) / 2.0
area = sqrt(s*(s-a)*(s-b)*(s-c))
print "The area is %.2f" % area
main()
你知道怎么了吗?
目前没有回答
相关问题 更多 >
编程相关推荐