我们的几何老师给了我们一个作业,要求我们创建一个玩具在现实生活中使用几何的例子,所以我认为编写一个程序来计算需要多少加仑的水来填充一个特定的水池会很酷形状,并具有一定的尺寸。
这是到目前为止的程序:
import easygui
easygui.msgbox("This program will help determine how many gallons will be needed to fill up a pool based off of the dimensions given.")
pool=easygui.buttonbox("What is the shape of the pool?",
choices=['square/rectangle','circle'])
if pool=='circle':
height=easygui.enterbox("How deep is the pool?")
radius=easygui.enterbox("What is the distance between the edge of the pool and the center of the pool (radius)?")
easygui.msgbox=("You need "+(3.14*(float(radius)**2) * float(height)) + "gallons of water to fill this pool.")
我不断收到此错误:
easygui.msgbox=("You need "+(3.14*(float(radius)**2) * float(height))
+ "gallons of water to fill this pool.")
TypeError: cannot concatenate 'str' and 'float' objects
我该怎么办?