こちらの質問のアウトプットがうまくいきません。
どなたか解決方法をお願い致します。
def main():
choice=input("Which currency do you want to convert into? Pick(Euro/Yen/Peso):\n")
dollars=float(input("Enter the amount in dollars:\n")
conversionRate=float(input("Enter the amount in dollars:\n"))
という部分の「conversionRate」というところにエラーがでます。
【2】 Choice Euro/Yen/Peso with multiple functions:
Create 3 Conversion functions. Create a function for converting Dollars to Euros. Create a function for converting Dollars to Yen. Create a function for converting Dollars to Mexican Pesos. Create a main function that handles the overall conversion exercise and invokes the functions for Euro, Yen, and Peso conversion based upon the user choice.
In the main function, if the user enters a dollar amount <=0, the user should be prompted and the program will stop executing. If the user enters a dollar amount > 0 the program should output the selected currency conversion.
・Create Pseudo Code/Whiteboard of the outline of the program. ・Attach Snipping Photo of Source Code and Output below.
def dollarsToEuros(dollars,conversionRate):
amountInEuros=dollars*conversionRate
print("Amount in Euros:",amountInEuros)
def dollarsToYen(dollars,conversionRate):
amountInYen=dollars*conversionRate
print("Amount in Yen:",amountInYen)
def dollarsToPeso(dollars,conversionRate):
amountInPeso=dollars*conversionRate
print("Amount in Peso:",amountInPeso)
def main():
choice=input("Which currency do you want to convert into? Pick(Euro/Yen/Peso):\n")
dollars=float(input("Enter the amount in dollars:\n")
conversionRate=float(input("Enter the amount in dollars:\n"))
if dollars<=0: print("Error:Amount less than or equal to 0\n" "Program will now exit...") quit() if choice.lower()=="euro": dollarsToEuros(dollars,conversionRate) elif choice.lower()=="yen": dollarsToYen(dollars,conversionRate) elif choice.lower()=="peso": dollarsToPeso(dollars,conversionRate) else: print("Error:Wrong choice!\n "Program will not exit...") quit()
if__name__=="main":
main()
回答2件
あなたの回答
tips
プレビュー