我不明白为什么当半径或高度是浮点数时以下内容无法正确运行并引发错误。
def cone(radius, height):
if isinstance(radius, int) or isinstance(radius,float) == False:
raise TypeError("Error: parameters radius and height must be numeric.")
if isinstance(height, int) or isinstance (height,float)== False:
raise TypeError("Error: parameters radius and height must be numeric.")
if radius > 0 and height > 0:
return ((radius*radius)*(3.1415)*(height/3))
if radius<=0:
raise ValueError("Error: radius must be positive.")
if height <=0:
raise ValueError("Error: height must be positive.")
蝴蝶不菲
慕神8447489
心有法竹
相关分类