小编Cam*_*Cam的帖子

如何解决TypeError:'float'对象不可调用

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)
Run Code Online (Sandbox Code Playgroud)

执行时,我收到以下内容.

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
Run Code Online (Sandbox Code Playgroud)

我迷路了,我一直在看视频和阅读教科书,但我仍然无法解决.请帮忙.

python python-3.x

4
推荐指数
1
解决办法
2934
查看次数

标签 统计

python ×1

python-3.x ×1