|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- a = eval(input())
- b = eval(input())
- c = eval(input())
- def isTriangle(a,b,c):
- if a+b>c and a+c>b and b+c>a:
- return 1
- else:
- return 0
- def TriArea():
- p = (a+b+c)/2
- area = (p*(p-a)(p-c)(p-b))**0.5
- return area
- if isTriangle(a,b,c) == 1:
- print("{},{}和{}能构成三角形,面积为{}".format(a,b,c,TriArea()))
- else:
- print("{},{}和{}不能构成三角形!".format(a,b,c))
复制代码
运行后显示TypeError: 'float' object is not callable是为什么捏?
缺少了乘号*
- a = eval(input())
- b = eval(input())
- c = eval(input())
- def isTriangle(a,b,c):
- if a+b>c and a+c>b and b+c>a:
- return 1
- else:
- return 0
- def TriArea():
- p = (a+b+c)/2.0
- area = (p*(p-a)*(p-c)*(p-b))**0.5
- return area
- if isTriangle(a,b,c) == 1:
- print("{},{}和{}能构成三角形,面积为{}".format(a,b,c,TriArea()))
- else:
- print("{},{}和{}不能构成三角形!".format(a,b,c))
复制代码
|
|