20
我们的几何老师给了我们一个任务,要求我们创建一个玩具在现实生活中使用几何的例子,所以我认为制作一个程序来计算需要多少加仑的水来填充一个池一定的形状和一定的尺寸。无法连接'str'和'float'对象?
这是迄今为止该程序:
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 =( “你需要” +(3.14×(浮动(半径)** 2)*浮动( )+“加仑水充满此池”) TypeError:无法连接'str'和'float'对象
我该怎么办?