2017-06-11 6 views
0

コードはすべて正常に動作しています。私はバット部分に問題があります。例えば、バットなしの価格は100ポンド、バートは20ポンドだと言いますが、一緒に追加すると153ポンドになります。それはどこから得られるのでしょうか 私の2番目の問題は私はあなたが別の価格を動作するようにしたいですし、彼らがそう言うのならば、プログラム全体が間違った値については、再びあなたの助けを私のバットの正しい番号を得ることができません

length = int(raw_input("what is the length of all you walls added together? 
")) 
while 2 > length or length > 26: 
    length = int(raw_input("what is the height of all you walls added 
    together? ")) 
else: 
    print ("okay") 
height = int(raw_input("what is the length of all you walls added together? 
")) 
while 1 > height or height > 6: 
    height = int(raw_input("what is the height of your room? ")) 
else: 
    print ("okay") 
area = height*length 
paint = raw_input("what paint would you like to use luxury paint, Standard 
quality, Economy quality? ") 
if paint == "LP" or "lp" or "luxery paint": 
    LP = 2 
    answer = LP*area  
if paint == "SQ": 
    SQ = 1.25 
    answer = SQ*area  
if paint == "EQ": 
    EQ = 0.55 
    answer = EQ*area 
undercoat = raw_input("would you like an undercoat?") 
if undercoat == "yes": 
    undercoat = area*0.55 
    novat = answer + undercoat 
elif undercoat == "no": 
    novat = answer 
percentage = (novat/100.00)*20 
print percentage 
cost = (novat + percentage) 
print "Interior Decorator" 
print "invoice" 
print "the price will be "+ unichr(163) + str(answer) +"(excluding vat)" 
print "the vat will be "+ unichr(163) + str(percentage) 
print "your grand total is " + unichr(163) + str(cost) 

おかげ

+1

生成された? – lit

+0

Pythonでデバッグを開始する簡単な方法は、このpdb行を貼り付けることです: 'import pdb; pdb.set_trace() 'を呼び出して、期待したことをしていないコードの直前に置いて、実行前に変数(例えば、' print(foo) ')を調べます。 –

答えて

0

を再開頼むように、ループを追加しようとしているイム:

見ると、cost = (novat + percentage)です。価格を印刷するときanswerの代わりにnovat変数を使用しないでください。あなたはあなたのコード上の例のような方法で、ループを抽出することができ

:別の実行をループについて

def main_logic(): 
    # The code you have above 

while True: 
    main_logic() 
    run_again = raw_input("would you like to run again? ") 
    if run_again != "yes": 
     break 
あなたがプログラムをステップ実行や値を調べるために使用しているデバッガ
関連する問題