【发布时间】:2018-09-22 12:04:06
【问题描述】:
import math
def reportSphereVolume(r):
SphereVolume = ((4/3)*math.pi*((r)**3))
return SphereVolume
def reportSphereSurfaceArea(r):
SphereSurfaceArea = ((4)*math.pi((r)**2))
return SphereSurfaceArea
radius = int(input("What is the radius of the sphere? " ))
reportSphereVolume(radius)
reportSphereSurfaceArea(radius)
执行时我收到以下信息。
What is the radius of the sphere? 10
Traceback (most recent call last):
File "D:\Thonny\SphereAreaVolume.py", line 16, in <module>
reportSphereSurfaceArea(radius)
File "D:\Thonny\SphereAreaVolume.py", line 11, in reportSphereSurfaceArea
SphereSurfaceArea = ((4)*math.pi((r)**2))
TypeError: 'float' object is not callable
我迷路了,我一直在看视频和阅读教科书,但我仍然无法解决。 请帮忙。
【问题讨论】:
-
非常感谢您的回复。我现在明白我的错误了。从现在开始我会小心的。我现在无法打印这些值...有什么想法吗?
-
每个人都会犯这种错误,即使是经验丰富的程序员。祝您继续接受编程教育。当计时器用完时,您应该接受其中一个答案。对于您的打印问题,请发布一个新问题,其中包含与您在此处所做的类似的示例代码。
标签: python python-3.x