import vending_machine.vending_service as m flag = True #控制迴圈是否繼續執行 while flag: print('\n============================') select = eval(input('1.儲值\n2.購買\n3.查詢餘額\n4.離開\n請選擇:')) if select == 1: pass elif select == 2: pass elif select == 3: pass elif select == 4: print('bye') flag = 0 #也可以=false break else: print('====請輸入1-4之間====') continue if select == 1: #儲值 m.deposit() elif select == 2: #購買 m.buy() elif select == 3: print(f'目前餘額為{m.balance}元')
# # 3/19 販賣機 import vending_machine.vending_service as machine flag = True while flag: print('\n==============================') select = eval(input('1. 儲值\n2. 購買\n3. 查詢餘額\n4. 離開\n請選擇:')) if select == 1: # 儲值 machine.deposit() elif select == 2: # 購買 machine.buy() elif select == 3: # 查詢餘額 print(f"目前餘額為{machine.balance}元") elif select == 4: # 離開 print("bye") flag = False break else: # 重新輸入 print('====請輸入1-4之間====') continue # # x = 100 # y = 80 # # def add_weight(w1, w2=1) : # result = w1 + w2
import vending_machine.vending_service as machine flag = True #控制迴圈是否執行 while flag: print('\n=====================') select = eval(input('1.儲值\n2.購買\n3.查詢餘額\n4.離開\n請選擇:')) if select == 1: #儲值 machine.deposit() elif select == 2: #購買 machine.buy() #ctrl按著點他會跳到上面 elif select == 3: #查詢餘額 print(f'目前餘額為{machine.balance}元') elif select == 4: print('\nbyebye 小可愛不要喝太多') flag = False break else: #重新輸入 print('====請輸入1-4之間====') continue