编写一个程序,提示用户输入三维圆锥体的半径和高度,然后计算并打印圆锥体的表面积和体积。表面积和体积的计算将在函数中完成,以及输入的收集。在
此部分的程序将按以下方式运行:打印出一条信息,说明程序的功能。在
提示用户输入以英尺为单位的半径(非负浮动)。在
提示用户输入以英尺为单位的高度(非负浮动)。在
打印半径和高度,但四舍五入为两位小数。在
打印表面积和体积,四舍五入到两位小数。在
以下是我目前所做的:import math
print("This Program will calculate the surface area and volume of a cone."
"\nPlease follow the directions.")
print()
print()
r = input(str("What is the radius in feet? (no negatives): "))
h = input(str("What is the height in feet? (no negatives): "))
math.pi = (22.0/7.0)
math.sqrt()
surfacearea = int(math.pi*r**2)+int(r*math.pi(math.sqrt(r**2+h**2)))
print("The surface area is", surfacearea)
print()
volume = (1/3)*math.pi*r**2*h
print ("The volume is", volume)
print()
print("Your Answer is:")
print()
print("A cone with radius", r, "\nand hieght", h,"\nhas a volume of : ",volume,
"\nand surface area of", surfacearea,)
我总是犯错误
^{pr2}$
有人能帮我通过这个小墙吗?我认为“漂浮”是问题的一部分。
我认为设置是好的,但执行是个问题。在