Coding Project
Part 1
Bill's Budget Adventures, a tourist company, has asked you (an indie developer) to build a utility app that helps their customers figure out the cost of items in the countries they visit on a trip. Bill thinks the app should run on any mobile phone, laptop, or desktop computer, since his customers come from all over the world. But, he is happy for you to create a prototype of the app that runs on desktop only. He needs the app to always use the latest information about exchange rates for each of the tourist destinations.
Coding Requirements
In this part of the project, you are required to construct a Python 3 project that satisfies the following:
? Use the provided web_utility.py module - it allows you to read the HTML content of a Web page, given a valid URL string (note: this module is available under the Assessment link)
? Create a module called currency that contains the following functions:
- convert()
- get_details()
? Create a module called trip that contains the following three classes:
- Error
- Country
- Details
Currency Module Details
convert(amount, home_currency_code, location_currency_code)
? The first parameter is an amount of money, and the other parameters are currency codes.
? Use the provided web_utility module to load data from the Google Finance currency converter Web page (see below) to convert the given amount of money in the home currency to the amount in the location currency. Example:
- calling currency.convert(1, 'AUD', 'JPY') returns 86.2379 (so $1 Australian dollars converts to about $86.24 Japanese yen).
- Calling currency.convert(86.2379, 'JPY', 'AUD') returns 1.0004.
? If this function is used incorrectly (e.g. trying to convert from AUD to AUD) or some other problem occurs (e.g. can't read data from the Web page) then the value returned must be - 1.
? To implement this function, apply your knowledge of text processing to extract the necessary monetary information from the Web page results.
Here is an example of using web_utility to convert $1 from AUD to JPY:
url_string = "https://www.google.com/finance/converter?a=1&from=AUD&to=JPY"
result = web_utility.load_page(url_string) print(result[result.index('result'):])
Here is the output (string) for this code:
'result>1 AUD = 85.9474 JPY\n\n