Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 通过输入获取半径并查找表面积和体积的程序 这就是我对立方体所做的,所以按照相同的格式,我需要相同的东西,但对于球体。_Python_Python 3.x_Math_Input - Fatal编程技术网

Python 通过输入获取半径并查找表面积和体积的程序 这就是我对立方体所做的,所以按照相同的格式,我需要相同的东西,但对于球体。

Python 通过输入获取半径并查找表面积和体积的程序 这就是我对立方体所做的,所以按照相同的格式,我需要相同的东西,但对于球体。,python,python-3.x,math,input,Python,Python 3.x,Math,Input,球体的表面积是4pix半径**2,体积是4/3pix半径**3,所以 导入数学 radius=int(输入('给我球体的半径')) 面积=4*math.pi*(半径**2) 体积=(4/3)*math.pi*(半径**3) 打印('球体的体积为',体积',面积为',面积) 与其他公式完全相同: #cube lengthC= input('Give me the side length of your cube') areaC=6*(int(lengthC)**2)

球体的表面积是4pix半径**2,体积是4/3pix半径**3,所以

导入数学
radius=int(输入('给我球体的半径'))
面积=4*math.pi*(半径**2)
体积=(4/3)*math.pi*(半径**3)
打印('球体的体积为',体积',面积为',面积)

与其他公式完全相同:

#cube
        lengthC= input('Give me the side length of your cube')
        areaC=6*(int(lengthC)**2)
        volumeC =(int(lengthC)**3)
        print('The volume of your cube is', volumeC, 'and your area is', areaC)
输出:

import math

lengthC= input("Give me the side length of your cube: ")
areaC=6*(int(lengthC)**2)
volumeC =(int(lengthC)**3)
print('The volume of your cube is', volumeC, 'and your area is', areaC)

lengthR  = input("Give me the radius of the sphere: ")
volumE   = (4/3) * math.pi * (float(lengthR)**3)
areaE    = 4 * math.pi * (float(lengthR)**2)
print('The volume of your sphere is', volumE, 'and your area is', areaE)
Give me the side length of your cube: 3
The volume of your cube is 27 and your area is 54
Give me the radius of the sphere: 9
The volume of your sphere is 3053.6280592892786 and your area is 1017.8760197630929