Python 通过输入获取半径并查找表面积和体积的程序 这就是我对立方体所做的,所以按照相同的格式,我需要相同的东西,但对于球体。
球体的表面积是4pix半径**2,体积是4/3pix半径**3,所以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)
导入数学
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