93.8k views
0 votes
The program below converts US Dollars to Euros, British Pounds, and Japanese Yen # Complete the functions USD2EUR, USD2GBP, USD2JPY so they all return the correct value def USD2EUR(amount): """ Convert amount from US Dollars to Euros. Use 1 USD = 0.831467 EUR args: amount: US dollar amount (float) returns: value: the equivalent of amount in Euros (float) """ #TODO: Your code goes here value = amount * 0.831467 return value

User ElJackiste
by
5.2k points

1 Answer

2 votes

Answer:

The program in Python is as follows:

def USD2EUR(amount):

EUR = 0.831467 * amount

return EUR

def USD2GBP(amount):

GBP = 0.71 * amount

return GBP

def USD2JPY(amount):

JPY = 109.26 * amount

return JPY

USD = float(input("USD: "))

print("Euro: ",USD2EUR(USD))

print("GBP: ",USD2GBP(USD))

print("JPY: ",USD2JPY(USD))

Step-by-step explanation:

This defines the USD2EUR function

def USD2EUR(amount):

This converts USD to Euros

EUR = 0.831467 * amount

This returns the equivalent amount in EUR

return EUR

This defines the USD2GBP function

def USD2GBP(amount):

This converts USD to GBP

GBP = 0.71 * amount

This returns the equivalent amount in GBP

return GBP

This defines the USD2JPY function

def USD2JPY(amount):

This converts USD to JPY

JPY = 109.26 * amount

This returns the equivalent amount in JPY

return JPY

The main begins here

This gets input for USD

USD = float(input("USD: "))

The following passes USD to each of the defined functions

print("Euro: ",USD2EUR(USD))

print("GBP: ",USD2GBP(USD))

print("JPY: ",USD2JPY(USD))

Note the program used current exchange rates for GBP and JPY, as the rates were not provided in the question

User Gentiane
by
5.2k points