質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

2回答

394閲覧

outputがでず、困っています2

airberry

総合スコア16

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2017/07/06 04:09

こちらの質問のアウトプットがうまくいきません。
どなたか解決方法をお願い致します。

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()

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

LouiS0616

2017/07/06 04:15

いや、ですから、コードをバッククオートで括って見やすくしてください。それだけで一気に回答者の負担が減ります。
can110

2017/07/06 04:28

「どんな」エラーが出ていますか?
guest

回答2

0

ベストアンサー

dollars=float(input("Enter the amount in dollars:\n")
末尾の)が足りてません。
dollars=float(input("Enter the amount in dollars:\n"))
に修正ください。

エラーメッセージを読む(+理解する)ようにしましょう。

投稿2017/07/06 04:30

can110

総合スコア38258

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

airberry

2017/07/06 04:36

ありがとうございます!修正できました!
guest

0

dollars=float(input("Enter the amount in dollars:\n")で、かっこが足りないのでは?

投稿2017/07/06 04:14

編集2017/09/01 05:06
xxBadMoon2017

総合スコア114

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問