2017-10-28 13 views
0
print("hello") 

def vendingMachine(): 

    count = 0 
    totalCredit = 0 
    coinNum = int(input("how many coins would you like to enter?:")) 
    while count in range (coinNum): 
     coin = float(input("enter coin: £")) 
     totalCredit = totalCredit + coi 
     count = count + 1 
    print("you have £{0} in your bank.".format (round(totalCredit,2))) 
    print("") 
    print("choose your item:") 
    print("") 
    print("1.coca cola") 
    print("2.lucozade") 
    print("3.7up") 
    print("4.fanta orange") 
    print("5.pepsi") 
    print("6.Diet pepsi") 
    print("7.mountain dew") 
    print("8.rubicon") 
    print("9.Dr Pepper") 
    print("10.sprite") 
    print("") 
    finalCredit = totalCredit 
    round (finalCredit, 2) 
    item = int(input("enter the number for your item:")) 
    while item <1 or item >10: 
     print("this item is not available.") 
     item = int(input("enter the nuber for your item: ")) 
    if item == 1: 
     finalCredit = totalCredit - 0.59 
     print ("you now have a Coca cola can, costing £0.59.") 
     print ("you have {0} remaining in your bank.".format (round(finalCredit,2))) 

に表示されていない(F5)これが起動する:Pythonコード私はそれを実行したときのpython 3.4.2シェル

私はそれはとても完全なコードだけではなく、「ハロー現れ作るのですか
>>> ================================ RESTART =============================== 
>>> 
hello 
>>> 

「PythonのIDLE 3.4.2 を使用して イムiは 感謝

答えて

0

あなたの機能を呼び出さなかったためです。 Pythonファイルの最後にこれらのコードを追加してください。そしてプログラムをもう一度実行してください。

if __name__ == "__main__": 
    vendingMachine() 
1

は、右あなたが関数を定義するコードの後の関数を呼び出す行を追加しますユーチューブ動画からこれをコピーしました。

vendingMachine() 

もう一度実行すると、他のコードが実行されます。

あなたはを定義しました。(ined)関数は呼び出しましたが、決して呼び出しませんでした。

関連する問題