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'對象
我該怎麼辦?