def rectangle_area():
"""returns a given rect_width and rect_height to rect_area"""
rect_width = float(input("rectangle width: "))
rect_height = float(input("rectangle height: "))
result = rect_width * rect_height
print("the area of the rectangle is: ", result)
rectangle_area()input进来的字符串,要用float转换为浮点数才能计算。
这段是python 3. x的代码,用python 2.x的话,将input改为raw_input