0
DEF主():Python的貨幣轉換器具有兩個功能
Print_menu()
currency_converter()
1)Print_menu函數應該是空隙不帶參數
DEF Print_menu():
print('Please choose from the menu.')
print('============================')
print('1: Convert between USD and EUR')
print('2: Convert between USD and Canada')
print('3: Convert between USD and UK (GBP)')
print('4: Convert between USD and China')
print('5: Quit')
print('============================')
menu = int(input('Enter your Choice: '))
2 )這currency_converter函數需要兩個參數,匯率和
貨幣單位的名稱。這可能是無效的,需要匯率和單位
來計算和打印結果。我在編寫代碼方面非常新,並且無法確定如何調用這些函數來創建工作程序。感謝提前任何輸入
高清currency_converter():
while menu >=1 and menu <=4:
if menu == 1:
menu = int(input('Enter the amount in dollar: '))
men1 = menu
men1 = menu * 91/100
print('\t','$', menu,'is', format(men1,'.2f'),'euro')
elif menu == 2:
menu = int(input('Enter the amount in dollar: '))
men1 = menu
men1 = menu * 137/100
print('\t','$', menu, 'is', format(men1,'.2f'), 'cad')
elif menu == 3:
menu = int(input('Enter the amount in dollar: '))
men1 = menu
men1 = menu * 72/100
print('\t','$', menu, 'is', format(men1,'.2f'), 'pound')
elif menu == 4:
menu = int(input('Enter the amount in dollar: '))
men1 = menu
men1 = menu * 653/100
print('\t','$', menu, 'is', men1, 'yuan')
if menu == 5:
print('Thank you for using my program.')
else:
print(menu, 'is an invalid choice.')
3)一旦貨幣被選中,我需要一個while循環來詢問是否要TO-
另一個單位轉換。我目前仍在撰寫這部分內容,並對我能做到這一點充滿信心。
的main()
歡迎來到Stack Overflow!一定要以可讀的方式格式化你的問題 - 尤其是對於那些重要的python! –