Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Back Hands-on 16 json apis-1.docx . There are lots of public APIs on the web - I found a ton on GitHub - https://github.com/public-apis/public-apis -

image text in transcribed
Back Hands-on 16 json apis-1.docx . There are lots of public APIs on the web - I found a ton on GitHub - https://github.com/public-apis/public-apis - We will use a Free Currency Rates API from GitHub Our call will be to get currency rates with USD (US dollars) as the base rate Together we will build a program to enter a country code and get an exchange value for an amount entered by the user. Steps: 1. Import libraries: Import json From urllib.request import urlopen 2. Make a call to the api: with urlopen("http://www.floatrates.com/daily/usd.json") as response: source = response.read() 3. Covert the json to a dictionary: data = json.loads(source) 4. Pull out the rates, keyed by country code: countries = data["usd"] 5. Write a loop to get the country code and amount to convert from the user a. Let the user know if they entered an incorrect country code b. Convert the amount to the country's currency c. Print the new amount d. Ask the user if they want to try another country 10 POINTS EXTRA CREDIT This same site offers a list of country codes to country names Pull down that json api and use it to put the full country name in the output to the user. http://www. floatrates. com/daily/us d. json Upload your py file and output to canvas. Let me know if you tried the extra credit. Sample Output, with extra credit: Enter a country currency to convert to: aud Enter an amount to convert: $100 A $100 US dollars is worth $136.4034 in Australian dollar Another? Y or N: y Enter a country currency to convert to: bch Enter an amount to convert: $100 A $100 US dollars is worth $0.1494 in Bitcoin Cash Another? Y or N: y Enter a country currency to convert to: irp Country code of irp not found Another? Y or N: y Enter a country currency to convert to: in Enter an amount to convert: $100 A $100 US dollars is worth $7434.726600000001 in Indian rupee Another? Y or N: N

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Programming questions