我们的几何老师给了我们一个作业,要求我们创建一个玩具在现实生活中使用几何的例子,所以我认为编写一个程序来计算需要多少加仑的水才能填满一个特定的水池。形状,并具有一定的尺寸。注意,这是在 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 行看到。它只是不会这样做......我做错了什么?