0
我们的几何老师给了我们一个任务,要求我们创建一个玩具在现实生活中使用几何图形的例子,所以我认为制作一个程序来计算需要多少加仑的水来填充一个池一定的形状和一定的尺寸。注意,这是在Python中。为什么我的程序不应该停止,我该如何解决?
这是迄今为止该程序:
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':
hei=easygui.enterbox("How deep is the pool?")
radi=easygui.enterbox("What is the distance between the edge of the pool and the center of the pool (radius)?")
areaC=3.14*(float(radi)**2) * float(hei)
easygui.msgbox=("You need " + str(areaC) + "gallons of water to fill this pool.")
每次我去8号线(areac = 3.14 ...),该程序似乎停止,并且不显示错误,好像该程序已经完成,但它应该显示在第9行中看到的池的体积。它只是不会做到这一点,虽然... 我做错了什么?
你说得对!这是我忽视的那个愚蠢的等号!在Python中,等号赋予easygui.msgbox一个值,所以程序实际上应该在那里。很多,这真的有帮助!现在我觉得很愚蠢太大声了。:) – user2443381