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 行看到。它只是不会这样做......我做错了什么?

4

1 回答 1

2

我不知道 python,所以我可能 100% 错了,但是在第 2 行你写“easygui.msgbox(”,在第 0 行你写“easygui.msgbox=(”) 等号与它有什么关系?

于 2013-06-06T03:12:02.813 回答