输入圆柱的高和半径,求圆柱体积,volume=π×r2×h 。要求定义和调用函数cylinder (r, h )计算圆柱体的体积。
输入格式:
输入在一行中给出2个实数,分别为半径r和高h。
输出格式:
在一行中以“Volume = 值”的形式输出圆柱体的体积,结果保留三位小数。
输入样例:
3.0 10
输出样例:
Volume = 282.743
答案
r,h = map(float,input().split())
import math
pi = math.pi
def cylinder(r,h):
return r*r*h
c = pi*cylinder(r,h)
print("Volume = %.3f"%c)