2013-06-06 58 views
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行中看到的池的體積。它只是不會做到這一點,雖然... 我做錯了什麼?

回答

2

我不知道蟒蛇,所以我可能是100%錯誤的,但在第2行你寫「easygui.msgbox(」 和在線0你做「easygui.msgbox =(」 是否等號與它有什麼關係?

+1

你說得對!這是我忽視的那個愚蠢的等號!在Python中,等號賦予easygui.msgbox一個值,所以程序實際上應該在那裏。很多,這真的有幫助!現在我覺得很愚蠢太大聲了。:) – user2443381

相關問題